Back to Devexpress

TcxCustomGridView.StoreDataViewState(TcxGridStorageOptions) Method

vcl-cxgridcustomview-dot-tcxcustomgridview-dot-storedataviewstate-x28-cxgridcustomview-dot-tcxgridstorageoptions-x29.md

latest8.9 KB
Original Source

TcxCustomGridView.StoreDataViewState(TcxGridStorageOptions) Method

Stores specified user interaction states in memory.

Declaration

delphi
procedure StoreDataViewState(AOptions: TcxGridStorageOptions);

Parameters

NameTypeDescription
AOptionsTcxGridStorageOptions

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 | gsoFocusedViewStore the focus position.gsoSelectedStores selection.gsoTopRecordStores the grid View scroll position.gsoExpandedStores the expanded status for all records.gsoDetailStores 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:

delphi
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);
cpp
#include "FireDAC.Comp.Client.hpp" // Declares the TFDQuery component
#include "cxGrid.hpp" // Declares the TcxGrid control
#include "cxGridCustomView.hpp" // Declares the TcxCustomGridView class and related types
#include "cxGridDBTableView.hpp" // Declares the TcxGridDBTableView class

// Add the following linker directives to the corresponding CPP source file:
#pragma link "FireDAC.Comp.Client" // Required to use FireDAC.Comp.Client.hpp declarations
#pragma link "cxGrid" // Required to use cxGrid.hpp declarations
#pragma link "cxGridCustomView" // Required to use cxGridCustomView.hpp declarations
#pragma link "cxGridDBTableView" // Required to use cxGridDBTableView.hpp declarations
// ...

  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 | RestoreFromIniFileAllow you to store the grid View state (both data layout and user interaction states) in an INI file.StoreToRegistry | RestoreFromRegistryAllow you to store the grid View state (both data layout and user interaction states) in the system registry.StoreToStorage | RestoreFromStorageAllow you to store the grid View state (both data layout and user interaction states) in a custom data format.StoreDataViewStateToStream | RestoreDataViewStateFromStreamAllow 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

TcxCustomTreeList.StoreDataViewState Procedure

TcxCustomGridView Class

TcxCustomGridView Members

cxGridCustomView Unit