Skip to main content
All docs
V26.1
  • DxGrid.ClearSelection() Method

    Clears selection.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.Grid.v26.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public void ClearSelection()

    Remarks

    Grid rows can be selected in the following ways:

    • Users click rows, tap rows, or execute keyboard shortcuts to select rows. 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 Microsoft.EntityFrameworkCore
    @inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
    @implements IDisposable
    
    <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; }
        NorthwindContext Northwind { get; set; }
        IReadOnlyList<object> SelectedDataItems { get; set; }
        IGrid MyGrid { get; set; }
    
        protected override void OnInitialized() {
            Northwind = NorthwindContextFactory.CreateDbContext();
            GridDataSource = Northwind.Products
                .ToList();
            SelectedDataItems = GridDataSource.Skip(1).Take(2).ToList();
        }
    
        public void Dispose() {
            Northwind?.Dispose();
        }
    }
    

    Blazor Grid Select and Deselect Data Item

    Run Demo: Data Grid - Selection API

    For additional information about selection in the Grid component, refer to the following topic: Selection and Focus in Blazor Grid.

    Implements

    See Also