Skip to main content
All docs
V24.1

DxTreeList.SelectedDataItemChanged Event

In single selection mode, fires when a TreeList row is selected.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public EventCallback<object> SelectedDataItemChanged { get; set; }

Parameters

Type Description
Object

The data item that corresponds to the newly selected row.

Remarks

The SelectedDataItemChanged event fires each time the SelectedDataItem property changes. This property specifies the data item that corresponds to the selected TreeList row in single selection mode.

The event is handled automatically when you use two-way data binding for the SelectedDataItem property (@bind-SelectedDataItem). You can also implement a custom event handler to respond to selection changes.

The following example allows users to click a row to select it and displays information about that row:

@inject EmployeeTaskService EmployeeTaskService

<DxTreeList Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            AllowSelectRowByClick="true"
            SelectionMode="TreeListSelectionMode.Single"
            @bind-SelectedDataItem="@SelectedDataItem">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

<div>
    <p><b>Selected task:</b> @((SelectedDataItem as EmployeeTask)?.Name ?? "(none)")</p>
</div>

@code {
    List<EmployeeTask> TreeListData { get; set; }
    object SelectedDataItem { get; set; }

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }
}

Blazor TreeList Obtain Selected Data Item

For more information about selection in the TreeList component, refer to the following topic: Selection and Focus in Blazor TreeList.

See Also