Skip to main content

Saving and Restoring Layout

  • 2 minutes to read

#Saving and Restoring Layout Basics

The DXGrid for Silverlight control allows you to save the information on its layout to a data store (an XML file or stream) and restore it when required. This information may include the visibility, position and size of visual elements, filter, sorting, grouping and summary information, etc. Multiple options allow you to specify the settings that need to be saved and restored when a layout is saved/restored.

To save the grid's layout, use the following methods: DataControlBase.SaveLayoutToStream or DataControlBase.SaveLayoutToXml. To restore the layout, use the DataControlBase.RestoreLayoutFromStream or DataControlBase.RestoreLayoutFromXml method.

NOTE

To correctly save and restore a grid layout, grid columns should be uniquely identified, using the x:Name attribute.

#Layout Options

Option

Description

DXSerializer.StoreLayoutMode

Specifies which settings should be saved.

Property Values:

None - nothing is saved or restored.

All - all settings are saved/restored. These include the visual, data-aware, behavior, customization options, etc.

UI (Default Value) - only those settings that are marked with the GridUIProperty attribute are saved/restored. These include visibility state, position and size of columns, sorting and grouping settings, summary information, etc.

#Layout Loading Specifics

There are two options that specify what to do with the columns that exist in a layout that is being loaded, but not in a current grid. By default, columns that exist in the current grid, but not in the layout that is being loaded, are retained. Also, columns that exist in a layout that is being loaded, but not in the current grid's layout, are destroyed. To change this behavior use the DataControlSerializationOptions.AddNewColumns and DataControlSerializationOptions.RemoveOldColumns properties.

#Example

How to: Serialize the Grid's Layout