Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeList.SelectedDataItemChanged Event

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

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[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