- 2 minutes to read
When a control's layout is saved to a data store, a specific set of properties is saved by default. For example, in the DXGrid control these include the visibility state of the entire control, the position and size of the columns/fields, sorting, grouping and summary information, settings that determine the visibility of various individual visual elements, etc.
By default, only predefined settings are saved. A property is saved/restored if it meets the following requirements.
The property must be marked with an DevExpress.Utils.Serializing.XtraSerializableProperty attribute.
DXGrid and DXPivotGrid provide the GridStoreAlwaysProperty and PivotStoreAlwaysProperty attributes, respectively. Properties marked with these attributes are always saved.
- The local value of the property must be set.
It is possible to manually specify which properties should be saved. This can be done in two ways: using the DXSerializer.StoreLayoutMode attached property or by handling the DXSerializer.AllowPropertyEvent attached event.
Select Settings via the StoreLayoutMode Attached Property
The following table describes the DXSerializer.StoreLayoutMode property values.
Specifies which settings should be saved.
None - only those settings that are marked with the special attribute (DXGrid: GridStoreAlwaysProperty; DXPivotGrid: PivotStoreAlwaysProperty) are saved/restored.
All - all settings that are marked with the XtraSerializable attribute and have their local value set are saved/restored. These generally include the visual, data-aware, behavior and customization options.
UI (Default Value) - only those settings that are marked with the GridUIProperty attribute are saved/restored. These include the visibility state, position and size of columns, sort and group settings, and summary information.
Select Settings by Handling an Event
To manually control which settings should be saved, handle the DXSerializer.AllowPropertyEvent attached event. The event parameter's DependencyProperty property represents a property that should be saved/restored. To save it, set the event parameter's Allow property to true. To see an example, refer to the How to: Select Properties to be Saved when Saving the Grid Layout topic.