vcl-dxbackend-dot-connectionstring-dot-json-dot-dataset.md
A component designed to fetch data from one or multiple datasets (TDataSet descendant instances).
TdxBackendDataSetJSONConnection = class(
TdxBackendCustomInMemoryJSONConnection
)
TdxBackendDataSetJSONConnection is a data connection component designed to bind a TdxReport or TdxDashboardControl component to one or multiple datasets (TdxMemData, TFDTable, TFDQuery, etc.) like any other data-aware VCL control (TcxGrid, for instance).
The TdxBackendDataSetJSONConnection component serializes data from associated datasets and stores it in memory in the JSON format[1].
The list below outlines key members of the TdxBackendDataSetJSONConnection class. These members allow you to configure data connection settings.
ActiveSpecifies if the data connection is active.AutoRefreshDataSpecifies if the data connection component automatically reloads data from associated datasets every time a backend client component starts to populate placeholders with data.DisplayNameSpecifies the data connection’s name in both designer and Collection Editor dialogs.ConnectionStringProvides access to serialized data (in the JSON format) from associated datasets. Use the DataSets property to manage the source dataset collection.DataSetsAllows you to manage source datasets.
Collection | IndexSpecify the parent collection component.
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
dxBackend.ConnectionString.JSON.DataSet; // Declares the TdxBackendDataSetJSONConnection component
// ...
procedure TMyForm.Button1Click(Sender: TObject);
var
ADataConnection: TdxBackendDataSetJSONConnection;
AReport: TdxReport;
ALayoutStream: TStream;
begin
ADataConnection := TdxBackendDataSetJSONConnection.Create(Self);
try
ADataConnection.Name := 'DataSetJSONData';
ADataConnection.DataSets.Add('Data', FDataSource);
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;
#include "dxReport.hpp" // Declares the TdxReport component and related types
#include "dxBackend.ConnectionString.JSON.DataSet.hpp" // Declares the TdxBackendDataSetJSONConnection component
// Add the following linker directives to the corresponding CPP source file:
#pragma link "dxReport" // Required to use dxReport.hpp declarations
#pragma link "dxBackend.ConnectionString.JSON.DataSet" //Required to use TdxBackendDataSetJSONConnection declarations
// ...
void __fastcall TMyForm::Button1Click(TObject *Sender)
{
TdxBackendDataSetJSONConnection *ADataConnection;
TdxReport *AReport;
TStream *ALayoutStream;
ADataConnection = new TdxBackendDataSetJSONConnection(this);
try
{
ADataConnection->Name = "DataSetJSONData";
ADataConnection->DataSets->Add("Data", FDataSource);
AReport = new TdxReport(this);
try
{
AReport->ReportName = "Report";
ALayoutStream = FLayoutDataSet->CreateBlobStream(FLayoutDataSet->FieldByName("Layout"), bmRead);
try
{
AReport->Layout->LoadFromStream(ALayoutStream);
}
__finally
{
delete ALayoutStream;
}
AReport->Language = "fr-FR";
AReport->ExportFormats = TdxReportExportFormats() << TdxReportExportFormat::PDF
<< TdxReportExportFormat::RTF << TdxReportExportFormat::HTML;
AReport->FilterString = "id = 5";
AReport->ShowViewer();
}
__finally
{
delete AReport;
}
}
__finally
{
delete ADataConnection;
}
}
The following public API members reference the TdxBackendDataSetJSONConnection class as a TdxBackendCustomDataConnection object:
TdxBackendDataConnectionCollection.AddCreates a data connection of the required type and ads the connection to the collection.TdxBackendDataConnectionCollection.ItemsProvides indexed access to all data connection components stored in the collection.TdxBackendDataConnectionManager.ItemsProvides indexed access to stored data connection components.
TdxBackendInMemoryJSONConnectionA component designed for interaction with data stored in memory.TdxBackendDatabaseSQLConnectionA non-visual component designed to fetch data from a relational database (SQL Server, PostgreSQL, SQLite, etc.).
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 DevExpress VCL 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:
TObject TPersistent TComponent TcxCustomComponent TcxComponentCollectionItem TdxBackendCustomDataConnection TdxBackendCustomInMemoryJSONConnection TdxBackendDataSetJSONConnection
Footnotes
See Also
Backend for VCL Reports/Dashboard