TcxCustomGridView.StoreDataViewState(TcxGridStorageOptions) Method
Stores specified user interaction states in memory.
Declaration
procedure StoreDataViewState(AOptions: TcxGridStorageOptions);
Parameters
Name | Type | Description |
---|---|---|
AOptions | TcxGridStorageOptions | Specifies a set of individual user interaction states stored in memory. |
Remarks
Call StoreDataViewState
and RestoreDataViewState procedures to save and restore specified user interaction states (selection, focus, the scroll position, etc.) during the same session.
Note
A RestoreDataViewState call clears all user interaction states saved using the StoreDataViewState
procedure.
If you need to store user interaction states in a separate stream, call StoreDataViewStateToStream and RestoreDataViewStateFromStream procedures.
View and User Interaction States
Pass a set of all required flags[1] as the AOptions
parameter to store/restore corresponding grid View states:
- gsoFocusedItem | gsoFocusedRecord | gsoFocusedView
- Store the focus position.
- gsoSelected
- Stores selection.
- gsoTopRecord
- Stores the grid View scroll position.
- gsoExpanded
- Stores the expanded status for all records.
- gsoDetail
- Stores the active detail grid View. Applicable only to master-detail grid View relationships.
Note
gsoUseFilter, gsoUseSummary, and gsoUseDataViewState flags have no effect on StoreDataViewState
/RestoreDataViewState and StoreDataViewStateToStream/RestoreDataViewStateFromStream procedure calls.
Use these flags in StoreToIniFile/RestoreFromIniFile, StoreToRegistry/RestoreFromRegistry, StoreToStorage/RestoreFromStorage, StoreToStream/RestoreFromStream calls instead.
Code Example: Restore the User Interaction State after Data Updates
The following code example restores selection, focus, and the scroll position after a refresh operation in the bound dataset:
uses
FireDAC.Comp.Client, // Declares the TFDQuery component
cxGrid, // Declares the TcxGrid control
cxGridCustomView, // Declares the TcxCustomGridView class and related types
cxGridDBTableView; // Declares the TcxGridDBTableView class
// ...
cxGrid1DBTableView1.StoreDataViewState(cxGridStoreAllDataViewStates);
FDQuery1.Refresh;
cxGrid1DBTableView1.RestoreDataViewState(cxGridStoreAllDataViewStates);
Other View State Store/Restore Methods
Alternatively, you can store grid View data layout and user interaction states in a stream, INI file, system registry, or custom storage. The TcxCustomGridView class implements the following Store~
/Restore~
method pairs in addition to StoreDataViewState
and RestoreDataViewState:
- StoreToIniFile | RestoreFromIniFile
- Allow you to store the grid View state (both data layout and user interaction states) in an INI file.
- StoreToRegistry | RestoreFromRegistry
- Allow you to store the grid View state (both data layout and user interaction states) in the system registry.
- StoreToStorage | RestoreFromStorage
- Allow you to store the grid View state (both data layout and user interaction states) in a custom data format.
- StoreDataViewStateToStream | RestoreDataViewStateFromStream
- Allow you to store only user interaction states in a separate stream.
-
Alternatively, you can use only the cxGridStoreAllDataViewStates constant if you need to store all user interaction states for the grid View as demonstrated in the code example in this topic.