Skip to main content

DxGrid.DeselectAllOnPage() Method

Deselects all rows on the current visible page.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void DeselectAllOnPage()

Remarks

The following methods allow you to manage Grid selection:

Call the DeselectAllOnPage method to remove all rows on the current page from selection. To add these rows to selection, call the SelectAllOnPage method.

Note

The Grid displays all rows on one page if the ShowAllRows or VirtualScrollingEnabled property is enabled. In this case, the DeselectAllOnPage method deselects all grid rows not hidden by the filter.

To access data items that correspond to selected rows, implement two-way binding for the SelectedDataItems property or handle the SelectedDataItemsChanged event.

@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.SelectAllOnPage()">Select All on Page</DxButton>
<DxButton Click="() => MyGrid.DeselectAllOnPage()">Deselect All on Page</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 All On Page

Run Demo: Data Grid - Selection API

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

Implements

See Also