Skip to main content
All docs
V25.1
  • TdxReportInMemoryJSONConnection Class

    A component designed for interaction with data stored in memory.

    Declaration

    TdxReportInMemoryJSONConnection = class(
        TdxReportCustomInMemoryJSONConnection
    )

    Remarks

    A data connection component allows you to bind a TdxReport component to data.

    Main API Members

    The list below outlines key members of the TdxReportInMemoryJSONConnection 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 in both Report Designer and Collection Editor dialogs.
    ConnectionString

    Specifies a connection string or source data (as a string 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
      dxReport.ConnectionString.JSON;  // Declares the TdxReportInMemoryJSONConnection component
    // ...
    
    procedure TMyForm.Button1Click(Sender: TObject);
    var
      AJSONDataConnection: TdxReportInMemoryJSONConnection;
      AReport: TdxReport;
      AFileStream: TFileStream;
    begin
      AJSONDataConnection := TdxReportInMemoryJSONConnection.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 TdxReportInMemoryJSONConnection Class References

    The following public API members reference the TdxReportInMemoryJSONConnection 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

    TdxReportDataSetJSONConnection
    A component designed to fetch data from one or multiple datasets (TDataSet descendant instances).
    TdxReportDatabaseSQLConnection
    A component designed to fetch data from an SQL database (SQL Server, PostgreSQL, SQLite, etc.).
    See Also