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

DxGrid.SelectAllOnPage(Boolean) Method

Selects or deselects all rows on the current visible page.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public void SelectAllOnPage(
    bool selected = true
)

Optional Parameters

Name Type Default Description
selected Boolean True

true to select the row; false to deselect the row.

Remarks

When the SelectionMode property is set to GridSelectionMode.Multiple, the SelectAllOnPage method allows you to select all the rows on the current page.

If you call the SelectAllOnPage method in GridSelectionMode.Single mode, it clears selection and selects only the last row on the current page.

To unselect all rows on the current page, use any of the following ways:

  • Call the DeselectAllOnPage() method.
  • Call the SelectAllOnPage method and pass false as the parameter.

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

You can also call the following methods to manage selection:

Run Demo: Data Grid - Selection API

See Also