Skip to content

Commit 24c260f

Browse files
committed
patch
1 parent 627294a commit 24c260f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,30 @@ begin
180180
end;
181181
```
182182

183+
### Step 6: Persist Data between Application Sessions
184+
185+
This step is applicable only to the memory-based [TdxMemData] datasource.
186+
187+
To save the dataset to a file and restore data on app restart,
188+
handle `OnCreate` and `OnDestroy` events of the data module:
189+
190+
```pas
191+
const
192+
DataFileName = 'data.dat';
193+
194+
procedure TDataModule1.DataModuleCreate(Sender: TObject);
195+
begin
196+
if FileExists(DataFileName) then
197+
mdLayouts.LoadFromBinaryFile(DataFileName)
198+
end;
199+
200+
procedure TDataModule1.DataModuleDestroy(Sender: TObject);
201+
begin
202+
if mdLayouts.RecordCount > 0 then
203+
mdLayouts.SaveToBinaryFile(DataFileName)
204+
end;
205+
```
206+
183207
## Files to Review
184208

185209
- [uData.pas]/[uData.cpp] stores dashboard layouts and supplies data to the dashboard.

0 commit comments

Comments
 (0)