Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Expand]Data Shaping
   [Expand]Data Analysis
   [Collapse]Layout
     Field Groups
     Data Cell Layout
     Field Location and Order
    [Expand]Customization Form
     Best Fit
     Standalone Field Header Areas
     Group Value
     Save and Restore Layout
   [Expand]Printing and Exporting
   [Expand]Appearance
   [Expand]MVVM Enhancements
   [Expand]Miscellaneous
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Save and Restore Layout

A pivot grid's layout contains settings which determine how its visual elements behave - their size, position within the control, etc. A layout can be saved and then applied to any other Pivot Grid control. This allows you to customize a pivot grid just once, and then apply the saved settings to other pivot grids in other WPF applications.

Expanded Base Concepts

Expanded DXPivotGrid Specifics

The DXPivotGrid provides multiple options, allowing you to specify which settings should be saved/restored. These options are described below:

Option Description
PivotSerializationOptions.AddNewFields Specifies whether the fields that currently exist in the pivot grid, but do not exist in a layout when it's restored, should be retained.
PivotSerializationOptions.AddNewGroups Specifies whether the field groups that currently exist in the pivot grid, but do not exist in a layout when it's restored, should be retained.
PivotSerializationOptions.RemoveOldFields Specifies whether fields that exist in a layout when it is restored, but don't currently exist in the pivot grid, should be discarded.
PivotSerializationOptions.StoreLayoutMode Gets or sets which settings should be saved when saving the PivotGrid's layout. This is an attached property.

To save the layout, use the PivotGridControl.SaveLayoutToXml or PivotGridControl.SaveLayoutToStream method. To restore the previously saved layout, use the PivotGridControl.RestoreLayoutFromXml or PivotGridControl.RestoreLayoutFromStream method.

Note that you should specify unique names for all pivot grid fields to correctly save and restore the layout. You can do this using the PivotGridField.Name property.

Expanded Example: How to Save and Load the DXPivotGrid's Layout

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2130.

The following example shows how to save the pivot grid's layout to a file in XML format. To investigate how this works, click the "Save" button, which calls the PivotGridControl.SaveLayoutToXml method. Once saved, the pivot grid's layout can then be restored by clicking the "Load" button, which calls the PivotGridControl.RestoreLayoutFromXml method.

Is this topic helpful?​​​​​​​