Skip to main content
All docs
V24.1

DxTreeList.SelectAllAsync(Boolean) Method

Selects or deselects all rows in the TreeList.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public Task SelectAllAsync(
    bool selected = true
)

Optional Parameters

Name Type Default Description
selected Boolean True

true to select all rows; false to deselect all rows.

Returns

Type Description
Task

The task that is completed when all rows are selected or deselected.

Remarks

The following methods allow you to manage TreeList selection:

Call the SelectAllAsync method to select or deselect all rows in the TreeList. This method does not affect the selection state of rows hidden by a filter.

If you call the SelectAllAsync(true) method when the SelectionMode property is set to Single, the method clears selection and selects only the last TreeList row.

To deselect all rows, call the SelectAllAsync(false) or DeselectAllAsync() method.

To access data items that correspond to selected rows, implement two-way binding for the SelectedDataItems property or handle the SelectedDataItemsChanged event.

@inject EmployeeTaskService EmployeeTaskService

<DxTreeList @ref="TreeList"
            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="SelectAll">Select All Rows</DxButton>
<DxButton Click="DeselectAll">Deselect All Rows</DxButton>

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

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }
    async Task SelectAll(MouseEventArgs args) {
        await TreeList.SelectAllAsync();
    }
    async Task DeselectAll(MouseEventArgs args) {
        await TreeList.DeselectAllAsync();
    }
}

Remote Data Source Limitations

DevExpress Blazor TreeList has the following specifics and limitations when it is bound to the GridDevExtremeDataSource or loads data on demand:

  • Sort and filter operations cancel incomplete “select all” and “deselect all” processes.
  • The second call to the SelectAllAsync or DeselectAllAsync method cancels the operation initiated by the previously called method.
  • SelectAllAsync and DeselectAllAsync methods load all data to the TreeList and can reduce overall performance and increase memory consumption.

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

See Also