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

Collapses all rows in the TreeList component.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void CollapseAll()

#Remarks

Call the ExpandAll or CollapseAll method to expand or collapse all rows in the TreeList component. To expand or collapse a specific row, pass the row’s visible index to the ExpandRow or CollapseRow method. The IsRowExpanded method returns whether a row with the specified visible index is expanded.

Enable the AutoExpandAllNodes property to automatically expand TreeList rows when the TreeList loads data.

#Limitations

The TreeList component does not support ExpandAll() and CollapseAll methods when it bound to server-mode data or loads data on demand.

#Example

The following example displays Expand All and Collapse All buttons in the TreeList toolbar:

@inject SpaceObjectDataProvider SpaceObjectDataProvider

<DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" />
        <DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
        <DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2">
            <HeaderCaptionTemplate>Mass, 10<sup>21</sup> &#215; kg</HeaderCaptionTemplate>
        </DxTreeListDataColumn>
        <DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2"/>
        <DxTreeListDataColumn FieldName="Volume10pow9KM3" DisplayFormat="N2">
            <HeaderCaptionTemplate>Volume, 10<sup>9</sup> &#215; km<sup>3</sup></HeaderCaptionTemplate>
        </DxTreeListDataColumn>
        <DxTreeListDataColumn FieldName="SurfaceGravity" DisplayFormat="N2">
            <HeaderCaptionTemplate>Gravity, m/s<sup>2</sup></HeaderCaptionTemplate>
        </DxTreeListDataColumn>
    </Columns>
    <ToolbarTemplate>
        <DxToolbar>
            <Items>
                <DxToolbarItem Text="Expand All" Click="() => TreeList.ExpandAll()" />
                <DxToolbarItem Text="Collapse All" Click="() => TreeList.CollapseAll()" />
            </Items>
        </DxToolbar>
    </ToolbarTemplate>
</DxTreeList>

@code {
    ITreeList TreeList { get; set; }
    object TreeListData { get; set; }

    protected override async Task OnInitializedAsync() {
        TreeListData = SpaceObjectDataProvider.GenerateData();
    }
}

Blazor TreeList Exapand All

#Implements

See Also