DxPivotTable.LoadLayout(PivotTablePersistentLayout) Method
Restores Pivot Table layout.
Namespace: DevExpress.Blazor.PivotTable
Assembly: DevExpress.Blazor.PivotTable.v25.1.dll
NuGet Package: DevExpress.Blazor.PivotTable
Declaration
public void LoadLayout(
PivotTablePersistentLayout layout
)
Parameters
Name | Type | Description |
---|---|---|
layout | PivotTablePersistentLayout | A PivotTablePersistentLayout object that stores the layout. |
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 LoadLayout
method to restore the Pivot Table’s layout on demand. As an alternative, handle the LayoutAutoLoading event to restore the layout when the component is initialized.
You can obtain an object that stores Pivot Table layout in one of the following ways:
- Use the LayoutAutoSaving event’s e.Layout argument.
- Use the object returned by the SaveLayout() method.
- Create an object that stores the Pivot Table layout manually and convert it to the PivotTablePersistentLayout type using the Deserialize method.
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);
}
}