DxDataGridComboBoxColumn<T>.DataAsync Property

Specifies an asynchronous function that returns column data.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Parameter]
public Func<CancellationToken, Task<IEnumerable<T>>> DataAsync { get; set; }

Property Value

Type Description
Func<CancellationToken, Task<IEnumerable<T>>>

A delegate that returns the data source.

Remarks

Use the DataAsync property to bind the column to a strongly typed collection that is loaded asynchronously (for instance, from an HTTP request). This property allows you to prevent the page from excessive re-rendering.

This property specifies an asynchronous function that returns a Task<IEnumerable<T>> object and accepts a CancellationToken object as a parameter. An exception occurs if you declare the function with an incorrect signature.

@using System.Threading

<DxDataGrid DataAsync="@GetForecastAsync">
    @*...*@
    <DxDataGridComboBoxColumn Field="@nameof(WeatherForecast.CloudCover)" Caption="Cloud Cover"
                                DataAsync="@GetCloudCoverAsync" TextAlignment="DataGridTextAlign.Left" />
</DxDataGrid>

@code {
    public class WeatherForecast {
        // ...
        public string CloudCover { get; set; }
    }

    public string[] CloudCover = new[] {
        "Sunny", "Partly cloudy", "Cloudy", "Storm"
    };

    public Task<IEnumerable<string>> GetCloudCoverAsync(CancellationToken ct = default) {
        return Task.FromResult(CloudCover.AsEnumerable());
    }

    public Task<IEnumerable<WeatherForecast>> GetForecastAsync(CancellationToken ct = default) {
        var rng = new Random();
        return Task.FromResult(Enumerable.Range(1, 15).Select(index => new WeatherForecast {
            // ...
            CloudCover = CloudCover[rng.Next(0, CloudCover.Length)],
        }).AsEnumerable());
    }
}

Use the Data property if a strongly typed collection is loaded synchronously. Use the CustomData property if your data is stored on a remote service and is loaded through a Web API.

Run Demo: Data Grid - Column Types

See Also