The Pivot Grid allows you to save the information on its layout, and then restore it. This information includes all the settings that control the visibility and size of visual elements, their appearance settings, filtering, sorting, etc.
ASPxPivotGrid exposes the following methods that allow you to save the pivot grid layout to a stream or string:
Restores the pivot grid layout from the specified string.
To allow the pivot grid's layout to be correctly saved and restored, ensure that unique names are specified for all pivot grid fields. Use the PivotGridField.ID property to provide a unique name for a field.
Each of the SaveLayoutTo... and LoadLayoutFrom... methods has two overloads - with and without the options parameter of the PivotGridWebOptionsLayout type.
When calling the SaveLayoutTo... and LoadLayoutFrom... methods without the options parameter, only a subset of the control's settings is saved/restored. By default, these settings include:
Gets or sets whether all the control's settings (except for the appearance settings and format rules) are stored when the layout is saved to storage and restored when the layout is restored from storage.
Gets or sets whether all the settings of a control's columns/bands (except for the appearance settings) are stored when the layout is saved to storage and restored when the layout is restored from storage.
Another approach to specify which options need to be saved/restored is to use the SaveLayoutTo... and LoadLayoutFrom... methods with the options parameter. You can create an instance of the PivotGridWebOptionsLayout class, customize it, and pass it as the options parameter. Only options that are enabled in this object will be saved/restored. Specific options that are disabled in the options parameter are not affected.
To save all layout options (without appearance, data and client-side events settings), pass null (Nothing in Visual Basic) or the static PivotGridWebOptionsLayout.FullLayout property as the options parameter.
The ASPxPivotGrid allows you to control the upgrading of a layout while it is being loaded from a data store (a stream or string).
You need to assign this property to distinguish between the versions of stored layouts and the current ASPxPivotGrid layout. If the versions do not match, you can customize the control to prevent the current layout from being overwritten.
Use the LayoutUpgradeEventArgs.PreviousVersion property to get the version of the layout being restored. Depending on the result, you can implement the required routine that will upgrade the old layout.
Partial Public Class _Default
Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
Session("Layout") = ASPxPivotGrid1.SaveLayoutToString()
Protected Sub ASPxButton2_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim layout As String = CStr(Session("Layout"))
If layout Is Nothing Then