TdxReportDataSetJSONConnection Class
A component designed to fetch data from one or multiple datasets (TDataSet descendant instances).
Declaration
TdxReportDataSetJSONConnection = class(
TdxReportCustomInMemoryJSONConnection
)
Remarks
TdxReportDataSetJSONConnection
is a data connection component designed to bind a Report Generator (TdxReport) to one or multiple datasets (TdxMemData, TFDTable, TFDQuery, etc.) like any other data-aware VCL control (TcxGrid, for instance).
The TdxReportDataSetJSONConnection
component serializes data from associated datasets and stores it in memory in the JSON format[1] compatible with the DevExpress Reports for Web engine (used as the base for TdxReport).
Main API Members
The list below outlines key members of the TdxReportDataSetJSONConnection
class. These members allow you to configure data connection settings.
Data Connection Settings
- Active
- Specifies if the data connection is active.
- AutoRefreshData
- Specifies if the data connection component automatically reloads data from associated datasets every time a TdxReport component starts to generate a report for design, preview, and export operations.
- DisplayName
Specifies the data connection’s name in both Report Designer and Collection Editor dialogs.
The DisplayName property value is used to refer to the data connection in the report template.
- ConnectionString
- Provides access to serialized data (in the JSON format) from associated datasets. Use the DataSets property to manage the source dataset collection.
- DataSets
- Allows you to manage source datasets.
General-Purpose API Members
- Collection | Index
- Specify the parent collection component.
Code Example: Load and Populate Report Templates from Datasets
This code example loads an XML-based report template (REPX) from a dataset, configures export settings, populates the template with data from another dataset, and displays the report preview:
uses
dxReport, // Declares the TdxReport component and related types
dxReport.ConnectionString.JSON.DB; // Declares the TdxReportDataSetJSONConnection component
// ...
procedure TMyForm.Button1Click(Sender: TObject);
var
ADataConnection: TdxReportDataSetJSONConnection;
AReport: TdxReport;
ALayoutStream: TStream;
begin
ADataConnection := TdxReportDataSetJSONConnection.Create(Self);
try
ADataConnection.Name := 'DataSetJSONData';
ADataConnection.DataSets.Add('Data', FDataSet);
AReport := TdxReport.Create(Self);
try
AReport.ReportName := 'Report';
ALayoutStream := FLayoutDataSet.CreateBlobStream(FLayoutDataSet.FieldByName('Layout'), bmRead);
try
AReport.Layout.LoadFromStream(ALayoutStream);
finally
ALayoutStream.Free;
end;
AReport.Language := 'fr-FR';
AReport.ExportFormats := [TdxReportExportFormat.PDF,
TdxReportExportFormat.RTF, TdxReportExportFormat.HTML];
AReport.FilterString := 'id = 5';
AReport.ShowViewer;
finally
AReport.Free;
end;
finally
ADataConnection.Free;
end;
end;
Indirect TdxReportDataSetJSONConnection Class References
The following public API members reference the TdxReportDataSetJSONConnection
class as a TdxReportCustomDataConnection object:
- TdxReportDataConnectionCollection.Add
- Creates a data connection of the required type and adds the connection to the collection.
- TdxReportDataConnectionCollection.Items
- Provides indexed access to all data connection components stored in the collection.
- TdxReportDataConnectionManager.Items
- Provides indexed access to stored data connection components.
Other Report Data Connection Components
- TdxReportInMemoryJSONConnection
- A component designed for interaction with data stored in memory.
- TdxReportDatabaseSQLConnection
- A component designed to fetch data from an SQL database (SQL Server, PostgreSQL, SQLite, etc.).
Inheritance
-
You can use the ConnectionString property to access serialized dataset content (as a string in the JSON format).