Skip to main content
All docs
V25.1

TcxCustomGridView.RestoreDataViewState(TcxGridStorageOptions) Method

Restores user interaction states stored in memory after a StoreDataViewState procedure call.

Declaration

procedure RestoreDataViewState(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, scroll position, etc.) during the same session.

Note

  • The RestoreDataViewState procedure also clears all information saved using the StoreDataViewState procedure.
  • A RestoreDataViewState procedure call has no effect if no specified (AOptions) user interaction state is stored in memory (for example, if you did not call the StoreDataViewState or saved a different set of user interaction states).

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/restore the focus position.
gsoSelected
Stores/restores selection.
gsoTopRecord
Stores/restores the grid View scroll position.
gsoExpanded
Stores/restores the expanded status for all records.
gsoDetail
Stores/restores the active detail grid View. Applicable only to master-detail grid View relationships.

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) between sessions in an INI file.
StoreToRegistry | RestoreFromRegistry
Allow you to store the grid View state (both data layout and user interaction states) between sessions in the system registry.
StoreToStorage | RestoreFromStorage
Allow you to store the grid View state between sessions in a custom storage.
StoreDataViewStateToStream | RestoreDataViewStateFromStream
Allow you to store only user interaction states in a separate stream.
Footnotes
  1. 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.

See Also