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

Clears selection.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void ClearSelection()

#Remarks

TreeList rows can be selected in the following ways:

  • Users click rows, tap rows, or execute keyboard shortcuts to select rows. To enable this functionality, set the AllowSelectRowByClick property to true.
  • Users click checkboxes or radio buttons in the selection column. To display this column, declare a DxTreeListSelectionColumn object in the Columns template.
  • You call the Select* method. Refer to the TreeList’s member table for the list of available methods.

Call the ClearSelection method to clear selection of all rows on all pages, including rows hidden by a filter:

@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>
<br />
<DxButton Click="() => MyTreeList.ClearSelection()" CssClass="my-button" Text="Clear Selection" />

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

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
        SelectedDataItems = TreeListData.Skip(1).Take(2).ToList();
    }
}

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

See Also