Skip to main content
A newer version of this page is available. .

DxGrid.DeselectAllOnPage() Method

Deselects all rows on the current visible page.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void DeselectAllOnPage()

Remarks

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

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

Implements

See Also