Skip to main content

DxGrid.Columns Property

Allows you to add Grid columns.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment Columns { get; set; }

Property Value

Type Description
RenderFragment

A template (render fragment) that allows you to declare Grid columns.

Remarks

The Grid supports the following column types:

Bound Data Columns

These columns get their values from the bound data source. Use the Data property to bind the Grid to a data collection. Declare DxGridDataColumn objects in the Columns template and use each object’s FieldName property to assign data fields.

For more information, refer to the following topic: Create a Bound Column.

Unbound Data Columns

These columns display values that are not stored in the assigned data collection. To create an unbound column, declare a DxGridDataColumn object in the Columns template and specify the column’s UnboundType property. Then, define the UnboundExpression property or handle the UnboundColumnData event to calculate column values.

For more information, refer to the following topic: Create an Unbound Column.

Command Column

This column displays CRUD-related buttons (New, Edit, and Delete) and the Clear button that resets values in the filter row. To create this column, declare a DxGridCommandColumn object in the Columns template.

For more information, refer to the DxGridCommandColumn class description.

Selection Column

This column allows users to select and deselect rows. It contains checkboxes or radio buttons depending on selection mode. To create this column, declare a DxGridSelectionColumn object in the Columns template.

For more information, refer to the DxGridSelectionColumn class description.

The following example creates data columns and binds them to data fields from the assigned data collection:

@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: Data Binding Run Demo: Edit Data Run Demo: Selection Column View Example: Create a Foreign Key (ComboBox) Column

See Also