DxDataGrid<T>.SingleSelectedDataRowChanged Event

Occurs when a user changed selection in single selection mode.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

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

Parameters

Type Description
T

A data row.

Remarks

Handle the SingleSelectedDataRowChanged event to track selection changes in single selection mode.

NOTE

Set the SelectionMode property to SingleSelectedDataRow to enable single selection mode.

<DxDataGrid Data="@DataSource"
    SelectionMode="DataGridSelectionMode.SingleSelectedDataRow"
    SingleSelectedDataRow="@SelectedProduct"
    SingleSelectedDataRowChanged="@OnSelectedProductChanged">
    ...
</DxDataGrid>

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

    protected void OnSelectedProductChanged(Product product) {
        SelectedProduct = product;
        ...
    }

    protected override void OnInitialized() {
        ...
        SelectedProduct = DataSource.First();
    }
}

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

<DxDataGrid Data="@DataSource"
    @bind-SingleSelectedDataRow="@SelectedProduct">
    ...
</DxDataGrid>

@code {
    ProductFlat selectedProduct;
    public ProductFlat SelectedProduct {
        get { return selectedProduct; }
        set {
            selectedProduct = value;
            InvokeAsync(StateHasChanged);
        }
    }
}

Online Demo

Data Grid - Single Data Row Selection

See Also