DxDataGrid<T>.MultipleSelectedDataRowsChanged Event

Occurs when a user changed selection in multiple selection mode.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Parameter]
public Action<IEnumerable<T>> MultipleSelectedDataRowsChanged { get; set; }

Parameters

Type Description
IEnumerable<T>

The selected data rows.

Remarks

Handle the MultipleSelectedDataRowsChanged event to track selection changes in multiple selection mode.

NOTE

Set the SelectionMode property to OptimizedMultipleSelection to allow users to select multiple rows in the grid.

<DxDataGrid Data="@DataSource"
    SelectionMode="DataGridSelectionMode.MultipleSelectedDataRows"
    MultipleSelectedDataRows="@SelectedProducts"
    MultipleSelectedDataRowsChanged="@OnSelectedProductsChanged">
    ...
</DxDataGrid>

@code {
    IEnumerable<Product> DataSource;
    IEnumerable<Product> SelectedProducts { get; set; }

    protected void OnSelectedProductsChanged(IEnumerable<ProductFlat> products) {
        SelectedProducts = products;
        ...
    }

    protected override void OnInitialized() {
        ...
        SelectedProducts = DataSource.Take(2);
    }
}

Another way to implement this task is to use the two-way synchronization.

<DxDataGrid Data="@DataSource"
    SelectionMode="DataGridSelectionMode.MultipleSelectedDataRows"
    @bind-MultipleSelectedDataRows="@SelectedProducts">
    ...
</DxDataGrid>

@code {
    IEnumerable<ProductFlat> selectedProducts;
    IEnumerable<ProductFlat> SelectedProducts {
        get { return selectedProducts; }
        set {
            selectedProducts = value;
            ...
        }
    }
}

Online Demo

Data Grid - Multiple Data Rows Selection

See Also