TdxBackendInMemoryJSONConnection Class
A component designed for interaction with data stored in memory.
Declaration
TdxBackendInMemoryJSONConnection = class(
TdxBackendCustomInMemoryJSONConnection
)
Remarks
A data connection component allows you to bind a backend client component to data.
Main API Members
The list below outlines key members of the TdxBackendInMemoryJSONConnection class. These members allow you to configure core data connection settings.
Data Connection Settings
- Active
- Specifies if the data connection is active.
- DisplayName
Specifies the data connection’s name both in report/UI layout template designer and Collection Editor dialogs.
The DisplayName property value is used to specify the data connection name within report/UI layout templates.
- ConnectionString
Specifies a connection string (or stores serialized data in the JSON format).
Tip
Refer to the following topic for detailed information on JSON Data: Connection to a JSON Data Source.
General-Purpose API Members
- Collection | Index
- Specify the parent collection component.
Code Example: Generate Reports Based on In-Memory Data
The following code example loads an XML-based report template (TdxReport.Layout) from a REPX file, populates the template with test data defined in a connection string, and exports the resulting report as a PNG image:
uses
dxReport, // Declares the TdxReport component and related types
dxBackend.ConnectionString.JSON; // Declares the TdxBackendInMemoryJSONConnection component
// ...
procedure TMyForm.Button1Click(Sender: TObject);
var
AJSONDataConnection: TdxBackendInMemoryJSONConnection;
AReport: TdxReport;
AFileStream: TFileStream;
begin
AJSONDataConnection := TdxBackendInMemoryJSONConnection.Create(Self);
try
AJSONDataConnection.Name := 'JSONData';
// Specify in-memory report data as a connection string
AJSONDataConnection.ConnectionString :=
'Json=''[{"id":1, "caption":"test1"},{"id":2, "caption":"test2"}]''';
AReport := TdxReport.Create(Self);
try
AReport.ReportName := 'Report';
AReport.Layout.LoadFromFile('Report.repx'); // Loads a report template
AFileStream := TFileStream.Create('Report.png', fmOpenReadWrite);
try
AReport.ExportToImage(AFileStream); // Exports the report in the default image export format (PNG)
finally
AFileStream.Free;
end;
finally
AReport.Free;
end;
finally
AJSONDataConnection.Free;
end;
end;
Indirect TdxBackendInMemoryJSONConnection Class References
The following public API members reference the TdxBackendInMemoryJSONConnection class as a TdxBackendCustomDataConnection object:
- TdxBackendDataConnectionCollection.Add
- Creates a data connection of the required type and ads the connection to the collection.
- TdxBackendDataConnectionCollection.Items
- Provides indexed access to all data connection components stored in the collection.
- TdxBackendDataConnectionManager.Items
- Provides indexed access to stored data connection components.
Other Report Data Connection Components
- TdxBackendDataSetJSONConnection
- A component designed to fetch data from one or multiple datasets (TDataSet descendant instances).
- TdxBackendDatabaseSQLCOnnection
- A component designed to fetch data from an SQL database (SQL Server, PostgreSQL, SQLite, etc.).
Related Compiled Demos
To see TdxDashboardControl and TdxReport components in action, run BI Dashboards Designer/Viewer and Report Designer/Viewer demos in the VCL Demo Center installed with compiled VCL DevExpress demos. Click different items in the sidebar on the left to switch between demo features.
Tip
You can find full source code for installed compiled Report and Dashboard demos in the following folders:
- %PUBLIC%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressReports\
- %PUBLIC%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressDashboards\