Skip to content

Commit 95da7ce

Browse files
Apply suggestions from code review
Co-authored-by: Vladimir Abadzhev <vladimira@devexpress.com>
1 parent 438195c commit 95da7ce

1 file changed

Lines changed: 24 additions & 30 deletions

File tree

README.md

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# DevExpress Reports for Delphi/C++Builder – Store Report Layouts in a Database
99

1010
This example application stores [DevExpress report layouts][TdxReport.Layout] in a database.
11-
The application allows users to create and save report layouts, modify existing layouts, and open layouts in Report Designer/Viewer.
11+
The application allows users to create new layouts, modify existing layouts using the built-in Report Designer,
12+
and save layout customizations to the data source.
1213

1314

1415
## Prerequisites
@@ -20,23 +21,18 @@ The application allows users to create and save report layouts, modify existing
2021

2122
## Test the Example
2223

23-
1. Run the sample app and click **New Report** to create an empty database record.
24+
1. Run the sample app and click **New Report**.
2425
1. Click **Design Report** to display the [Report Designer][dx-report-designer] dialog.
2526
1. Create a report layout using tools available within the UI.
2627
2. Click the hamburger button, select the **Save** option, and close the dialog.
27-
2. Close the app. The [TdxMemData] component will store layout data in the [data.dat] file between sessions.
28-
3. Run the sample app again. Click **Design Report** to load the saved report layout,
29-
or **Preview Report** to preview a layout-based report in the [Report Viewer][dx-report-viewer] dialog.
28+
2. Close and restart the app.
29+
Click **Design Report** or **Preview Report** to load the saved report in the designer or [Report Viewer][dx-report-viewer].
3030

3131
## Implementation Details
3232

33-
Follow the instructions listed in this example to store report layouts in a desired database
34-
using the corresponding [TDataSet] descendant.
35-
36-
The example uses a memory-based dataset
37-
([TdxMemData] inherited from the [TDataSet] class shipped with the standard VCL library).
38-
Applications in this example encapsulate data components within separate data modules:
39-
[uData.pas] (Delphi) and [uData.cpp] (C++Builder).
33+
The example uses a DevExpress memory-based dataset as a report layout storage: [TdxMemData].
34+
You can modify the application to use any [TDataSet] descendant instead.
35+
To review the data module implementation, see the following file: [uData.pas]/[uData.cpp].
4036

4137
The instructions assume that you start with a Delphi or C++Builder project that already includes
4238
a configured data source for DevExpress Reports.
@@ -46,11 +42,10 @@ This example project uses a SQLite sample database ([nwind.db]) as a report data
4642

4743
### Step 1: Create a Dataset to Store Report Layout Data
4844

49-
Follow these steps to create a memory-based dataset intended to store report layout data:
5045

51-
1. Create a [TdxMemData] component on a form (`mdLayouts` in the example).
52-
2. Create a [TDataSource] component on a form (`dsLayouts` in the example).
53-
Assign the `TDataSource.DataSet` value to the previously created dataset component:
46+
1. Add a [TdxMemData] component to the data module (`mdLayouts` in the example).
47+
2. Add a [TDataSource] component to the data module (`dsLayouts` in the example).
48+
Assign the previously created dataset component to `TDataSource.DataSet`:
5449

5550
> <img src="./images/create-bind-data-source.png" style="width: 50%" alt=""/>
5651
@@ -68,9 +63,9 @@ Follow these steps to create a memory-based dataset intended to store report lay
6863
6964
6. (*Optional*) Preload persistent data to the dataset to make layouts available in the application upon first launch.
7065

71-
This example includes a sample report layout designed to use data from the Northwind sample database.
66+
This example includes a sample report layout that displays data from the Northwind sample database.
7267
You can preload it from [example.dat].
73-
Open the context menu for the dataset component, select **Persistent Editor…**, click **Load…** and select the file.
68+
Open the context menu for the dataset component, select **Persistent Editor…**, click **Load…**, and select the file.
7469

7570
> <img src="./images/create-persistent-data.png" style="width: 50%" alt=""/>
7671
@@ -109,8 +104,8 @@ The assigned report replaces the current layout definition.
109104

110105
### Step 3: Display Report Designer and Viewer
111106

112-
Once you have assigned name and layout to the [TdxReport] component,
113-
you can display the [Report Designer][dx-report-designer] and [Report Viewer][dx-report-viewer]:
107+
Once you assigned a name and layout to the [TdxReport] component,
108+
you can display [Report Designer][dx-report-designer] and [Report Viewer][dx-report-viewer] dialogs:
114109

115110
```pas
116111
procedure TMainForm.btnDesignClick(Sender: TObject);
@@ -131,7 +126,7 @@ end;
131126

132127
When a user edits and saves a report in the Report Designer,
133128
the value of [TdxReport.Layout] changes and an [OnLayoutChanged] event is called.
134-
Handle this event to automatically store the updated layout in the active dataset record.
129+
Handle this event to save layout changes to the active dataset record.
135130

136131
```pas
137132
procedure TMainForm.dxReport1LayoutChanged(ASender: TdxReport);
@@ -149,12 +144,11 @@ end;
149144
```
150145

151146

152-
### Step 5: Store the Database State Between Application Sessions
147+
### Step 5: Persist Data between Application Sessions
153148

154149
This step is applicable only to the memory-based [TdxMemData] datasource.
155150

156-
To store the database state when user closes the application
157-
and restore the state on app restart,
151+
To save the dataset to a file and restore data on app restart,
158152
handle `OnCreate` and `OnDestroy` events of the data module:
159153

160154
```pas
@@ -177,8 +171,8 @@ end;
177171

178172
## Files to Review
179173

180-
- [uData.pas] (Delphi) and [uData.cpp] (C++Builder) store/restore layout data to/from a memory-based dataset component ([TdxMemData]).
181-
- [uMainForm.pas] (Delphi) and [uMainForm.cpp] (C++Builder) supply layout data from the data module to [TdxReport] and display Report Designer and Viewer.
174+
- [uData.pas]/[uData.cpp] stores report layouts.
175+
- [uMainForm.pas]/[uMainForm.cpp] creates a [TdxReport], loads report layouts from the data module, and displays Report Designer/Viewer.
182176
- [data.dat] stores the memory-based dataset state between application sessions.
183177
- [nwind.db] contains the Northwind sample database used as a data source for report content.
184178

@@ -191,10 +185,10 @@ end;
191185
- [Store report layouts in REPX files at design-time][reports-design-time-store]
192186
- API reference:
193187
- [TdxReport.ReportName] (internal report name that is not included in the layout)
194-
- [TdxReport.Layout] (an XML-based layout template that can be stored in the BLOB field of a database)
195-
- [TdxMemData] (used to store report layout data in application runtime and between sessions)
196-
- [TDataSet] (ancestor of the [TdxMemData], contains generic database connection methods)
197-
- [TdxBackendDatabaseSQLConnection] (used to supply data to reports)
188+
- [TdxReport.Layout] (an XML-based layout template that can be stored in a BLOB data field)
189+
- [TdxMemData] (a DevExpress in-memory dataset implementation)
190+
- [TDataSet] (contains generic database connection methods)
191+
- [TdxBackendDatabaseSQLConnection] (supplies data to reports)
198192

199193
<!-- documentation links -->
200194
[reports-intro]: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports

0 commit comments

Comments
 (0)