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.DeselectRow(Int32) Method

Deselects a row with the specified visible index.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void DeselectRow(
    int visibleIndex
)

#Parameters

Name Type Description
visibleIndex Int32

The row’s visible index.

#Remarks

The following methods allow you to manage TreeList selection:

Pass a row’s visible index to the DeselectRow method to remove that row from selection. Call the SelectRow method to select a row with the specified visible index.

Note

Rows that are filtered out and child rows of collapsed items do not have visible indexes. You cannot change the selection state of such rows with DeselectRow and SelectRow methods.

When the TreeList is bound to the GridDevExtremeDataSource or loads data on demand, call the WaitForRemoteSourceRowLoadAsync(Int32) method before you execute the DeselectRow method to ensure that the specified data row is loaded.

To access data items that correspond to selected rows, do one of the following:

Tip

When you call the SelectRow or DeselectRow method, the component sends a callback and redraws the TreeList. If you select or deselect multiple rows, for instance, in a cycle, it can reduce overall performance. Call the SelectRows or DeselectRows method instead to avoid unnecessary callbacks and redraws.

The following example selects and deselects the first row:

@inject EmployeeTaskService EmployeeTaskService

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

<DxTreeList @ref="MyTreeList"
            Data="TreeListData"
            KeyFieldName="Id"
            ParentKeyFieldName="ParentId"
            AllowSelectRowByClick="true"
            @bind-SelectedDataItems="@SelectedDataItems">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
</DxTreeList>

<DxButton Click="() => MyTreeList.SelectRow(0)" CssClass="my-button" Text="Select First Row" />
<DxButton Click="() => MyTreeList.DeselectRow(0)" CssClass="my-button" Text="Deselect First Row" />

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

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

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

See Also