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.IsDataItemSelected(Object) Method

Returns whether the row that corresponds to the specified data item is selected.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public bool IsDataItemSelected(
    object dataItem
)

#Parameters

Name Type Description
dataItem Object

The data item.

#Returns

Type Description
Boolean

true if the corresponding row is selected; otherwise, false.

#Remarks

Call the IsDataItemSelected method to identify whether the row that corresponds to the specified data item is selected. The IsRowSelected method allows you to check whether the specified row is selected.

@inject EmployeeTaskService EmployeeTaskService

<style>
    .my-button {
        width: 200px;
    }
</style>

<DxTreeList @ref="MyTreeList"
            Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            @bind-SelectedDataItems="@SelectedDataItems">
    <Columns>
        <DxTreeListSelectionColumn />
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>
<DxButton Text="Is First Row Selected" CssClass="my-button"
          Click="() => IsRowSelectedInfo = MyTreeList.IsRowSelected(0)" />
<DxButton Text="Is First Data Item Selected" CssClass="my-button"
          Click="() => IsDataItemSelectedInfo = MyTreeList.IsDataItemSelected(TreeListData.First())" />

<div><b>Is First Row Selected</b>: @IsRowSelectedInfo</div>
<div><b>Is First Data Item Selected</b>: @IsDataItemSelectedInfo</div>

@code {
    List<EmployeeTask> TreeListData { get; set; }
    IReadOnlyList<object> SelectedDataItems { get; set; }
    ITreeList MyTreeList { get; set; }
    bool IsRowSelectedInfo { get; set; }
    bool IsDataItemSelectedInfo { get; set; }

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

Blazor TreeList Selection

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

See Also