vcl-dxbackend-dot-connectionstring-dot-json-dot-dataset-c1b17e25.md
A collection of backend dataset items.
TdxBackendDataSetCollection = class(
TcxComponentCollection
)
A backend dataset collection manages datasets (TDataSet descendants) for a TdxBackendDataSetJSONConnection component.
Associate a collection item with a dataset (TdxMemData, TFDTable, TFDQuery, etc.) using a TDataSource component (like any other data-aware VCL control, such as TcxGrid).
The list below outlines key members of the TdxBackendDataSetCollection class. These members allow you to manage datasets as data sources for backend client components.
AddCreates a new backend dataset item and adds it to the collection.ClearClears the collection.CountReturns the number of collection items accessible through the Items property.DeleteDeletes individual stored dataset collection items.Items
Provides indexed access to stored dataset collection items.
Tip
Cast the returned object to the TdxBackendDataSetCollectionItem class to access all public API members.
AssignCopies datasets between collections.BeginUpdate | EndUpdateAllow you to avoid redundant notifications during batch collection changes.
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 TdxBackendDataSetJSONConnection.DataSets property references a TdxBackendDataSetCollection object.
TObject TPersistent TcxComponentCollection TdxBackendDataSetCollection
See Also