Back to Devexpress

TdxBackendDataSetJSONConnection.DataSets Property

vcl-dxbackend-dot-connectionstring-dot-json-dot-dataset-dot-tdxbackenddatasetjsonconnection-f184876c.md

latest5.2 KB
Original Source

TdxBackendDataSetJSONConnection.DataSets Property

Provides access to the backend dataset collection.

Declaration

delphi
property DataSets: TdxBackendDataSetCollection read; write;

Property Value

TypeDescription
TdxBackendDataSetCollection

A backend dataset collection.

|

Remarks

Each backend dataset item in the DataSets collection allows you to use a dataset (a TDataSet descendant instance) as a data source for a backend client component.

The TdxBackendDataSetJSONConnection component serializes content from source datasets and stores it in memory in the JSON format. You can use the ConnectionString property to access serialized data (if required).

Available Options

Call the DataSets.Add method to create a new dataset item as demonstrated in the following code example: Load and Populate Report Templates from Datasets.

Refer to the TdxBackendDataSetCollection class description for detailed information on all available options.

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:

delphi
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;
cpp
#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;
  }
}

See Also

TdxBackendDataSetJSONConnection.AutoRefreshData Property

TdxBackendCustomInMemoryJSONConnection.ConnectionString Property

TdxBackendDataSetJSONConnection Class

TdxBackendDataSetJSONConnection Members

dxBackend.ConnectionString.JSON.DataSet Unit