Skip to main content
All docs
V25.2
  • TdxBackendCustomInMemoryJSONConnection Class

    The base class for JSON-based data connection components (TdxBackendInMemoryJSONConnection and TdxBackendDataSetJSONConnection).

    Declaration

    TdxBackendCustomInMemoryJSONConnection = class abstract(TdxBackendCustomDataConnection)

    Remarks

    A data connection component allows you to bind a backend client component to data. JSON-based Data Connection components store source data in a format compatible with the DevExpress Reports for Web engine (used as the base for TdxReport and TdxDashboardControl components).

    Main API Members

    The list below outlines key members of the TdxBackendCustomInMemoryJSONConnection 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 the report/UI layout template designer and Collection Editor dialogs.

    The DisplayName property value is used to specify the data connection name within report/UI layout templates.

    ConnectionString

    Specifies a connection string (or stores serialized data in the JSON format).

    Tip

    Refer to the following topic for detailed information on JSON Data: Connection to a JSON Data Source.

    SetJSONValue
    Sets component data to the specified JSON value.

    General-Purpose API Members

    Collection | Index
    Specify the parent collection component.

    Code Examples

    Assign JSON Data as a Connection String

    The following code example demonstrates an OnClick event handler that configures a TdxBackendInMemoryJSONConnection component, assigns a table defined within a JSON string to the ConnectionString property, and displays the Dashboard Designer dialog:

    uses
      dxDashboard.Control,  // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.JSON;  // Declares the TdxBackendInMemoryJSONConnection component
    // ...
    
    procedure TMyForm.cxButton1Click(Sender: TObject);
    begin
      // Specify a user-friendly data connection name (for end-user dialogs)
      dxBackendInMemoryJSONConnection1.DisplayName := 'Memory-Based JSON Data Source';
      // Define a table that consists of three columns ("id", "Region", and "Sales") and five data rows
      dxBackendInMemoryJSONConnection1.ConnectionString := 'Json=''' +
    
        '[{"id": 1, "Region": "Asia", "Sales": 4.7685},' +  // Row #1
         '{"id": 2, "Region": "Australia", "Sales": 1.9576},' + // Row #2
         '{"id": 3, "Region": "Europe", "Sales": 3.3579},' +  // Row #3
         '{"id": 4, "Region": "North America", "Sales": 3.7477},' + // Row #4
         '{"id": 5, "Region": "South America", "Sales": 1.8237}]'''; // Row #5
    
      dxDashboardControl1.ShowDesigner;  // Displays the Dashboard Designer dialog
    end;
    

    Assign a JSON Data String Directly

    The following code example demonstrates an OnClick event handler that calls the SetJSONValue procedure to assign a table defined within a JSON string to the TdxBackendInMemoryJSONConnection component and displays the Dashboard Designer dialog:

    uses
      dxDashboard.Control,  // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.JSON;  // Declares the TdxBackendInMemoryJSONConnection component
    // ...
    
    procedure TMyForm.cxButton1Click(Sender: TObject);
    var
      AJSONData: string;
    begin
      // Define a table that consists of three columns ("id", "Region", and "Sales") and five data rows
      AJSONData :=
    
      '[{"id": 1, "Region": "Asia", "Sales": 4.7685},' +  // Row #1
       '{"id": 2, "Region": "Australia", "Sales": 1.9576},' + // Row #2
       '{"id": 3, "Region": "Europe", "Sales": 3.3579},' +  // Row #3
       '{"id": 4, "Region": "North America", "Sales": 3.7477},' + // Row #4
       '{"id": 5, "Region": "South America", "Sales": 1.8237}]'; // Row #5
    
      // Specify a user-friendly data connection name (for end-user dialogs)
      dxBackendInMemoryJSONConnection1.DisplayName := 'Memory-Based JSON Data Storage';
      dxBackendInMemoryJSONConnection1.SetJSONValue(AJSONData);  // Assigns the defined JSON data string
      dxDashboardControl1.ShowDesigner; // Displays the Dashboard Designer dialog
    end;
    

    Load JSON Data from a Remote Source

    The code example in this section demonstrates an OnClick event handler that configures a TdxBackendInMemoryJSONConnection component used to load JSON data from an external source using a connection string and displays the Dashboard Designer dialog.

    Note

    This code example demonstrates a sample connection string. You must replace specified parameter values with required URI, username, password, access tokens, etc.

    uses
      dxDashboard.Control,  // Declares the TdxDashboardControl component
      dxBackend.ConnectionString.JSON;  // Declares the TdxBackendInMemoryJSONConnection component
    // ...
    
    procedure TMyForm::cxButton1Click(Sender: TObject);
    begin
      dxBackendInMemoryJSONConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs)
      dxBackendInMemoryJSONConnection1.DisplayName := 'Memory-Based JSON Data Source';
      dxBackendInMemoryJSONConnection1.ConnectionString :=
    
        'Uri=https://northwind.netcore.io/customers.json;' + // Specifies the path to a source JSON file
        'Username=user;' +  // Specifies a valid user name
        'Password=pwd;' + // Specifies the corresponding password for the user name
        'MyAuthHeader1=secretToken1;MyAuthHeader2=secretToken2;' +  // Specifies authentication tokens
        'query:id=123456;query:name=MyName;'  // Specifies the required query ID and name
    
      dxBackendInMemoryJSONConnection1.Active := True;  // Connects to the target Web service endpoint
      dxDashboardControl1.ShowDesigner();  // Displays the Dashboard Designer dialog
    end;
    

    Terminal TdxBackendCustomInMemoryJSONConnection Class Descendants

    Do not use the TdxBackendCustomInMemoryJSONConnection class directly. Use the following components instead:

    TdxBackendInMemoryJSONConnection
    A component designed for interaction with data stored in memory.
    TdxBackendDataSetJSONConnection
    A component designed to fetch data from one or multiple datasets (TDataSet descendant instances).
    See Also