Skip to main content
All docs
V26.1
  • DxGrid.DeselectDataItems(IEnumerable<Object>) Method

    Deselects rows that correspond to the specified data items.

    Namespace: DevExpress.Blazor

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

    NuGet Package: DevExpress.Blazor

    Declaration

    public void DeselectDataItems(
        IEnumerable<object> dataItems
    )

    Parameters

    Name Type Description
    dataItems IEnumerable<Object>

    A collection of data items.

    Remarks

    The following methods allow you to manage Grid selection:

    Call the DeselectDataItems method to remove the specified data items and corresponding rows from selection. To select rows and their data items, call the SelectDataItems method.

    To access selected data items, 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.SelectDataItems(dataItems)">Select Data Items 4-6</DxButton>
    <DxButton Click="() => MyGrid.DeselectDataItems(dataItems)">Deselect Data Items 4-6</DxButton>
    
    @code {
        IEnumerable<object> GridDataSource { get; set; }
        NorthwindContext Northwind { get; set; }
        IReadOnlyList<object> SelectedDataItems { get; set; }
        IGrid MyGrid { get; set; }
        IEnumerable<object> dataItems { get; set; }
    
        protected override void OnInitialized() {
            Northwind = NorthwindContextFactory.CreateDbContext();
            GridDataSource = Northwind.Products
                .ToList();
            SelectedDataItems = GridDataSource.Skip(1).Take(2).ToList();
            dataItems = GridDataSource.Skip(3).Take(3).ToList();
        }
    
        public void Dispose() {
            Northwind?.Dispose();
        }
    }
    

    Blazor Grid Select and Deselect Data Items

    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.

    See Also