Skip to main content
All docs
V24.1

DxTreeList.ClearSelection() Method

Clears selection.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

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();
    }
}

Blazor TreeList Select and Deselect Data Item

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

See Also