DxDataGridCheckBoxColumn Class

A data column that displays disabled checkboxes and is replaced with a combobox when users filter column values.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.dll

Declaration

public class DxDataGridCheckBoxColumn :
    DxDataGridCheckBoxColumnBase

Remarks

The DxDataGridCheckBoxColumn displays disabled checkboxes that support the checked, unchecked, and indeterminate states.

To switch the state in the edit form, users can click the checkbox or press SPACE when the checkbox is focused.

Blazor-Data-Grid-CheckBoxColumn-Checkboxes

NOTE

Online Demo: Data Grid - Column Types

Bind to Data

Use the Field property to bind the checkbox column to a field from the Data Grid's data source.

<DxDataGrid DataAsync="@ForecastService.GetForecastAsync" ...>
    ...
    <DxDataGridCheckBoxColumn Field="@nameof(WeatherForecast.Precipitates)">
    </DxDataGridCheckBoxColumn>
</DxDataGrid>

The field's values specify checkbox states. The field's type defines whether checkboxes support the indeterminate state.

Data Type

Checked State

Unchecked State

Indeterminate State

Boolean

true

false

(not supported)

Nullable Boolean

true

false

null

String

"true"

"false"

null

or any other value

Byte

Int32

UInt32

Int64

Decimal

Single

Double

1

0

other values

Other Data Types

See Bind to Custom Data Types for more information.

Bind to Custom Data Types

You can bind the checkbox column to a custom data type (Enum, Object, etc.) Use the following properties to explicitly specify how to consider type values:

  • ValueChecked - Specifies a value that corresponds to the checked state.
  • ValueUnchecked - Specifies a value that corresponds to the unchecked state.
  • ValueIndeterminate - Specifies a value that corresponds to the indeterminate state.

If a value is not equal to the specified properties, it is considered indeterminate.

The following example demonstrates how to bind the checkbox column to an Enum object:

<DxDataGrid Data="@Orders" ...>
    ...
    <DxDataGridCheckBoxColumn Field="@nameof(Order.OrderStatus)"
                              ValueChecked="@OrderStatus.Delivered"
                              ValueUnchecked="@OrderStatus.Processing"
                              ValueIndeterminate="@OrderStatus.InTransit"
                              Caption="Order Status">
    </DxDataGridCheckBoxColumn>
</DxDataGrid>
}

@code {
    IEnumerable<Order> Orders;

    protected override async Task OnInitializedAsync()
    {
        Orders = await OrderRepository.Load();
    }
}

Blazor-DataGrid-CheckBoxColumn-CustomType

NOTE

Online Demo: Data Grid - Filter Row

Filter Data

The filter row displays the combobox editor for the checkbox column. The editor contains items whose text corresponds to column states: True, False, and (optionally) Indeterminate.

Blazor-Data-Grid-CheckBoxColumn-Standard-FilterText

Use the following properties to show custom texts in the filter row's combobox editor:

The following example demonstrates how to bind the checkbox column to an Enum object and specify custom filter texts for all three states.

<DxDataGrid Data="@Orders" ...>
    ...
    <DxDataGridCheckBoxColumn Field="@nameof(Order.OrderStatus)"
                              FilterTextChecked="Delivered"
                              FilterTextUnchecked="Processing"
                              FilterTextIndeterminate="In transit"
                              ValueChecked="@OrderStatus.Delivered"
                              ValueUnchecked="@OrderStatus.Processing"
                              ValueIndeterminate="@OrderStatus.InTransit"
                              Caption="Order Status">
    </DxDataGridCheckBoxColumn>
</DxDataGrid>
}

@code {
    IEnumerable<Order> Orders;

    protected override async Task OnInitializedAsync()
    {
        Orders = await OrderRepository.Load();
    }
}

Blazor-Data-Grid-CheckBoxColumn-Custom-FilterText

NOTE

Online Demo: Data Grid - Filter Row

Switch Mode

Set the CheckType property to CheckType.Switch to display column values as toggle switches. In the edit form, users can select between the checked and unchecked states. The indeterminate state is not available in this mode.

<DxDataGrid DataAsync="@ForecastService.GetForecastAsync" ...>
    ...
    <DxDataGridCheckBoxColumn Field="@nameof(WeatherForecast.Precipitates)" CheckType="CheckType.Switch">
    </DxDataGridCheckBoxColumn>
</DxDataGrid>

Blazor-Data-Grid-CheckBoxColumn-Switches

Inheritance

See Also