DxDataGrid<T>.SetDataRowSelectedByKey(Object, Boolean) Method

Specifies selection state of a data row with the specified key.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

public Task SetDataRowSelectedByKey(
    object keyValue,
    bool selected
)

Parameters

Name Type Description
keyValue Object

A data row key.

selected Boolean

true to select a row; otherwise, false.

Returns

Type Description
Task

An asynchronous operation that specifies a data row’s selection state.

Remarks

Use the SetDataRowSelectedByKey method to select or clear selection from a row by its key.

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

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

    protected override async Task OnAfterRenderAsync(bool firstRender) {
        if (firstRender) {
            for (int i = 0; i < 10; i++)
                await grid.SetDataRowSelectedByKey(i, true);
        }
        // ...
    }
}

Online Demo

Data Grid - Selection

See Also