Skip to main content
All docs
V24.2

DxTreeList.SaveLayout() Method

Saves information about the TreeList layout.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public TreeListPersistentLayout SaveLayout()

Returns

Type Description
TreeListPersistentLayout

The current layout.

Remarks

The TreeList allows you to save and restore the component’s layout when necessary. You can use SaveLayout() and LoadLayout(TreeListPersistentLayout) methods for this purpose. The saved layout object includes the current page, page size, column sort order/direction, column position, and filter values. Information about row expansion states is not saved.

Use the SaveLayout method to save the TreeList layout on demand. To respond to each layout change automatically, handle the LayoutAutoSaving event.

To restore the saved layout, pass an object returned by the SaveLayout method to any of the following members:

Important

DevExpress components can incorrectly serialize custom enumeration values in criteria operators. Refer to the following troubleshooting topic for more information: The XXX enumeration type is not registered for the parse operation…

Example

The following code snippet displays two buttons: Save Layout and Load Layout. When a user clicks the first button, the current TreeList layout is saved to the Layout parameter. Once a user clicks the second button, the component loads the most recently-saved layout from the Layout parameter and applies it to the TreeList.

Save and Restore Layout on Demand

<DxButton Text="Load Layout" Click="OnLoadClick" />
<DxButton Text="Save Layout" Click="OnSaveClick" />

<DxTreeList @ref="MyTreeList"
            Data="@Data"
            CssClass="my-treelist"
            ShowFilterRow="true"
            KeyFieldName="ID" 
            ParentKeyFieldName="ParentID" 
            HasChildrenFieldName="HasChildren">
    <Columns>
        <DxTreeListDataColumn Caption="Location" FieldName="Name" />
        <DxTreeListDataColumn FieldName="CityType" />
        <DxTreeListDataColumn FieldName="Year" DisplayFormat="d"/>
        <DxTreeListDataColumn FieldName="RecordType" />
        <DxTreeListDataColumn FieldName="Population" />
    </Columns>
</DxTreeList>

@code {
    ITreeList MyTreeList { get; set; }
    TreeListPersistentLayout Layout { get; set; }

    void OnSaveClick() {
        Layout = MyTreeList.SaveLayout();
    }

    void OnLoadClick() {
        MyTreeList.LoadLayout(Layout);
    }

    object Data { get; set; }

    // ...
}

Run Demo: Save and Restore the Layout

Implements

See Also