Skip to main content
All docs
V25.1

DxPivotTable.SaveLayout() Method

Returns Pivot Table layout information so you can save it to a variable or a custom storage.

Namespace: DevExpress.Blazor.PivotTable

Assembly: DevExpress.Blazor.PivotTable.v25.1.dll

NuGet Package: DevExpress.Blazor.PivotTable

Declaration

public PivotTablePersistentLayout SaveLayout()

Returns

Type Description
PivotTablePersistentLayout

A PivotTablePersistentLayout object that stores layout information.

Remarks

The Blazor Pivot Table allows you to save and restore its layout between application work sessions. The layout information includes settings that users can change: field settings (area, area index, sort order, visibility), filter criteria, expanded/collapsed state of rows and columns.

Use the SaveLayout method to save the Pivot Table’s 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:

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

@rendermode InteractiveServer
@using Services

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

<DxPivotTable Data="SalesData" @ref=MyPivotTable >
    <Fields>
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Region)"
                           Area="@PivotTableArea.Row"
                           AreaIndex="0" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Country)"
                           Area="@PivotTableArea.Row"
                           SortOrder="@PivotTableSortOrder.Descending"
                           AreaIndex="1" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Date)"
                           GroupInterval="@PivotTableGroupInterval.DateYear"
                           Area="@PivotTableArea.Column"
                           AreaIndex="0"
                           Caption="Year" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Date)"
                           GroupInterval="@PivotTableGroupInterval.DateQuarter"
                           Area="@PivotTableArea.Column"
                           AreaIndex="1"
                           Caption="Quarter" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Amount)"
                           SortOrder="@PivotTableSortOrder.Ascending"
                           Area="@PivotTableArea.Data"
                           SummaryType="@PivotTableSummaryType.Sum" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.City)"
                           Area="@PivotTableArea.Filter"/>
    </Fields>
</DxPivotTable>

@code {
    IPivotTable MyPivotTable { get; set; }
    PivotTablePersistentLayout Layout { get; set; }
    IEnumerable<Sales.SaleInfo> SalesData;
    protected override async Task OnInitializedAsync() {
        SalesData = await Sales.GetSalesAsync();
    }
    void OnSaveClick() {
        Layout = MyPivotTable.SaveLayout();
    }
    void OnLoadClick() {
        MyPivotTable.LoadLayout(Layout);
    }
}

DevExpress Blazor Pivot Table - Save and Restore the Layout

Run Demo: Save and Restore the Layout

Implements

See Also