Skip to main content
A newer version of this page is available. .

DxGrid.Data Property

Specifies an object that supplies Grid data.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public object Data { get; set; }

Property Value

Type Description
Object

Supplies Grid data.

Remarks

Use the Data property to bind the Grid to data. To display data within the Grid, declare DxGridDataColumn objects in the Columns template and use each object’s FieldName property to assign data fields.

Bind to Data Synchronously

If your data collection is loaded synchronously, bind the Data property to a model field and initialize this field with data in the OnInitialized lifecycle method.

@inject WeatherForecastService ForecastService

<DxGrid Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="Date" DisplayFormat="D" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" Width="120px" />
        <DxGridDataColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" Width="120px" />
        <DxGridDataColumn FieldName="Forecast" />
        <DxGridDataColumn FieldName="CloudCover" />
    </Columns>
</DxGrid>

@code {
    object Data { get; set; }

    protected override void OnInitialized() {
        Data = ForecastService.GetForecast();
    }
}

Blazor Grid Data Binding

Run Demo: Grid - Data Binding

Bind to Data Asynchronously

If your data collection is loaded asynchronously, bind the Data property to a model field and initialize this field with data in the OnInitializedAsync lifecycle method.

@inject WeatherForecastService ForecastService

<DxGrid Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="Date" DisplayFormat="D" />
        <DxGridDataColumn FieldName="TemperatureC" Caption="@("Temp. (\x2103)")" Width="120px" />
        <DxGridDataColumn FieldName="TemperatureF" Caption="@("Temp. (\x2109)")" Width="120px" />
        <DxGridDataColumn FieldName="Forecast" />
        <DxGridDataColumn FieldName="CloudCover" />
    </Columns>
</DxGrid>

@code {
    object Data { get; set; }

    protected override async Task OnInitializedAsync() {
        Data = await ForecastService.GetForecastAsync();
    }
}

Blazor Grid Data Binding

Run Demo: Grid - Asynchronous Data Binding

Bind to Large Data

You can use the Blazor GridDevExtremeDataSource<T> to bind the Grid to a large IQueryable<T> data collection stored locally or published as an HTTP service. Refer to the GridDevExtremeDataSource<T> class description for more information and examples.

Run Demo: Grid - Large Data(Queryable)

Run Demo: Large Data (Queryable as HTTP Service)

Unbound Columns

The Data Grid allows you to add unbound columns whose values are not stored in the assigned data collection. You can calculate column values in two ways:

  • Specify the UnboundExpression that calculates an unbound column’s values based on other column values.
  • Handle the UnboundColumnData event to supply unique column values based on custom logic.

Fore more information and examples, refer to the following topic: DxGridDataColumn.

Implements

See Also