TcxCustomTreeList.RestoreDataViewState(TcxTreeListStorageOptions) Method
Restores user interaction states stored in memory after a StoreDataViewState procedure call.
Declaration
procedure RestoreDataViewState(AOptions: TcxTreeListStorageOptions);
Parameters
Name | Type | Description |
---|---|---|
AOptions | TcxTreeListStorageOptions | 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, node expanded status, 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 procedure 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.
Tree List User Interaction States
Pass a set of all required flags[1] as the AOptions
parameter to restore corresponding Tree List user interaction states:
- tsoFocusedItem | tsoFocusedRecord
- Store/restore the focus position.
- tsoSelected
- Stores/restores selection.
- tsoTopRecord
- Stores/restores the Tree List scroll position (the record at the top control border).
- tsoExpanded
- Stores/restores the expanded status for all nodes.
Note
The tsoUseDataViewState flag has no effect on StoreDataViewState/RestoreDataViewState
and StoreDataViewStateToStream/RestoreDataViewStateFromStream calls.
Use tsoUseDataViewState in StoreToIniFile/RestoreFromIniFile, StoreToRegistry/RestoreFromRegistry, and StoreToStream/RestoreFromStream calls to save/restore user interaction states in addition to the data layout.
Code Example: Restore User Interaction States after Data Refresh
The following code example restores selection, focus and scroll positions, and node expanded states after a refresh operation in the bound dataset:
uses
FireDAC.Comp.Client, // Declares the TFDQuery component
cxDBTL; // Declares the TcxDBTreeList class
// ...
cxDBTreeList1.StoreDataViewState(cxTreeListStoreAllDataViewStates);
FDQuery1.Refresh;
cxDBTreeList1.RestoreDataViewState(cxTreeListStoreAllDataViewStates);
Other Tree List Store/Restore Methods
Alternatively, you can store Tree List data layout and user interaction states in an INI file or the system registry. The TcxCustomTreeList class implements the following Store~
/Restore~
method pairs in addition to StoreDataViewState and RestoreDataViewState
:
- StoreToIniFile | RestoreFromIniFile
- Allow you to store the Tree List state (both data layout and user interaction states) in an INI file.
- StoreToRegistry | RestoreFromRegistry
- Allow you to store the Tree List state (both data layout and user interaction states) in the system registry.
- StoreToStream | RestoreFromStream
- Allow you to store the Tree List state (both data layout and user interaction states) in a stream.
- StoreDataViewStateToStream | RestoreDataViewStateFromStream
- Allow you to store user interaction states in a separate stream.
-
Alternatively, you can use only the cxTreeListStoreAllDataViewStates constant if you need to restore all user interaction states for the Tree List control as demonstrated in the code example in this topic.