DxGrid.ClearSelection() Method

Clears selection.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.2.dll

Declaration

public void ClearSelection()

Remarks

Grid rows can be selected in the following ways:

  • Users click rows to select them. To enable this functionality, set the AllowSelectRowByClick property to true.
  • Users click checkboxes or radio buttons in the selection column. To display this column, declare a DxGridSelectionColumn object in the Columns template.
  • You call the Select* method. Refer to the Grid’s member table for the list of available methods.

Call the ClearSelection method to clear selection of all rows on all pages.

@using Grid.Northwind
@inject NorthwindContext Northwind

<DxGrid Data="GridDataSource"
        AllowSelectRowByClick="true"
        @bind-SelectedDataItems="@SelectedDataItems"
        KeyFieldName="ProductId"
        @ref="MyGrid">
    <Columns>
        <DxGridDataColumn FieldName="ProductName" />
        <DxGridDataColumn FieldName="UnitPrice" />
        <DxGridDataColumn FieldName="QuantityPerUnit" />
        <DxGridDataColumn FieldName="UnitsInStock" />
    </Columns>
</DxGrid>
<br />

<DxButton Click="() => MyGrid.ClearSelection()">Clear Selection</DxButton>

@code {
    IEnumerable<object> GridDataSource { get; set; }
    IReadOnlyList<object> SelectedDataItems { get; set; }
    IGrid MyGrid { get; set; }

    protected override void OnInitialized() {
        GridDataSource = Northwind.Products
            .ToList();
        SelectedDataItems = GridDataSource.Skip(1).Take(2).ToList();
    }
}

Blazor Grid Select and Deselect Data Item

Run Demo: Data Grid - Selection API

Implements

See Also