DxDataGrid<T>.SetDataRowSelected(T, Boolean) Method

Specifies a data row’s selection state.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public void SetDataRowSelected(
    T dataRow,
    bool selected
)

Parameters

Name Type Description
dataRow T

A data row.

selected Boolean

true, to select a row; otherwise, clear selection from this row.

Remarks

Use the SetDataRowSelected method to select or clear selection from a row.

<DxDataGrid @ref="@grid"
    Data="@DataSource" 
    KeyFieldName="ID"
    SelectionMode="DataGridSelectionMode.OptimizedMultipleSelection">
    ...
</DxDataGrid>

@code {
    DxDataGrid<Product> grid;
    IEnumerable<Product> DataSource;

    protected override Task OnAfterRenderAsync(bool firstRender) {
        if (firstRender) {
            var products = DataSource.Take(10);
            foreach (var product in products)
                grid.SetDataRowSelected(product, true);
        }
        return base.OnAfterRenderAsync(firstRender);
    }
}

Online Demo

Data Grid - Selection

See Also