Skip to main content
All docs
V24.2

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

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