TcxGridStorageOptions Type
A set of flags that correspond to individual grid View settings and user interaction information stored in a file, stream, or system registry.
Declaration
TcxGridStorageOptions = set of TcxGridStorageOption;
Referenced Class
Type | Description |
---|---|
TcxGridStorageOption | A flag that corresponds to an individual grid View information storage option. |
Remarks
A TcxGridStorageOptions
value can include any TcxGridStorageOption flag to indicate required grid View settings and user interaction states.
You need to use gsoUseDataViewState together with all required flags when you call the following methods to store/restore corresponding user interaction states in addition to the data layout:
- TcxCustomGridView.StoreToIniFile | TcxCustomGridView.RestoreFromIniFile
- TcxCustomGridView.StoreToRegistry | TcxCustomGridView.RestoreFromRegistry
- TcxCustomGridView.StoreToStorage | TcxCustomGridView.RestoreFromStorage
- TcxCustomGridView.StoreToStream | TcxCustomGridView.RestoreFromStream
Tip
You can use only the cxGridStoreAllDataViewStates constant if you need to store all user interaction states (as demonstrated in the Code Examples section below).
Code Examples
Restore User Interaction States 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);
Store Grid View State Between Sessions
The code example in this section demonstrates form OnDestroy and OnCreate event handlers. These handlers call StoreToStream and RestoreFromStream procedures to save and restore user interaction states (selection, focus, scroll position, etc.) in addition to the filter state and summaries.
uses
System.SysUtils, // Declares the FileExists function
cxGrid, // Declares the TcxGrid control
cxGridCustomView, // Declares the TcxCustomGridView class and related types
cxGridDBTableView; // Declares the TcxGridDBTableView class
// ...
procedure TMyForm.FormCreate(Sender: TObject);
var
AFileStream: TFileStream;
begin
if FileExists('GridConfig.dat') then
begin
AFileStream := TFileStream.Create('GridConfig.dat', fmOpenReadWrite);
try
// Restore the grid view layout structure along with selected records and the current focus position
cxGrid1DBTableView1.RestoreFromStream(AFileStream, True, False,
[gsoUseFilter, gsoUseSummary] + cxGridStoreAllDataViewStates)
finally
AFileStream.Free;
end;
end;
end;
procedure TMyForm.FormDestroy(Sender: TObject);
var
AFileStream: TFileStream;
begin
AFileStream := TFileStream.Create('GridConfig.dat', fmCreate or fmOpenReadWrite);
try
// Save the grid view layout structure along with selected records and the current focus position
cxGrid1DBTableView1.StoreToStream(AFileStream,
[gsoUseFilter, gsoUseSummary] + cxGridStoreAllDataViewStates)
finally
AFileStream.Free;
end;
end;
Direct TcxGridStorageOptions Type References
View Information Store Procedures
The following information store procedures accept a TcxGridStorageOptions
value:
- TcxCustomGridView.StoreDataViewState
- Stores specified user interaction states in memory.
- TcxCustomGridView.StoreDataViewStateToStream
- Saves specified user grid View interaction states to a stream.
- TcxCustomGridView.StoreToIniFile
- Saves grid View state information to an INI file.
- TcxCustomGridView.StoreToRegistry
- Saves specified View data structure and user interaction information to the system registry.
- TcxCustomGridView.StoreToStorage
- Saves grid View data layout and user interaction states to a file in a custom data format.
- TcxCustomGridView.StoreToStream
- Saves specified View data structure and user interaction information to a stream.
View Information Restore Procedures
The following information restore procedures accept a TcxGridStorageOptions
value:
- TcxCustomGridView.RestoreDataViewState
- Restores user interaction states stored in memory after a StoreDataViewState procedure call.
- TcxCustomGridView.RestoreDataViewStateFromStream
- Restores the previously saved data view state from a stream.
- TcxCustomGridView.RestoreFromIniFile
- Restores previously saved grid View state information from an INI file.
- TcxCustomGridView.RestoreFromRegistry
- Restores previously saved grid View state information from the system registry.
- TcxCustomGridView.RestoreFromStorage
- Restores previously saved grid View state information from a file in a custom data format.
- TcxCustomGridView.RestoreFromStream
- Restores previously saved grid View state information from a stream.