Skip to main content
All docs
V25.2
  • TdxDashboard.EnableCustomSql Property

    Specifies if custom SQL queries are enabled for the loaded layout definition.

    Declaration

    property EnableCustomSql: TdxDefaultBoolean read; write; default bDefault;

    Property Value

    Type Default Description
    TdxDefaultBoolean bDefault

    Specifies if the current TdxDashboard container executes a custom SQL query created within the current layout definition:

    bDefault

    The TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql property specifies if the TdxDashboard container executes custom SQL queries.

    Tip

    This is a strongly recommended option that ensures the safety of SQL queries if the TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql property value is not modified.

    bTrue

    Custom SQL queries are explicitly enabled for the TdxDashboard container.

    Warning

    This option disables safety-related limitations on SQL queries at the TdxDashboard container level. Ensure that you set all necessary user read/write privileges at the database level.

    bFalse
    Custom SQL queries are explicitly disabled for the TdxDashboard container.

    Remarks

    A layout definition loaded using the Layout property may include a SQL query if the TdxDashboard container connects to a relational database system using the TdxBackendDatabaseSQLConnection component.

    Important

    Custom SQL queries specified within the dashboard layout definition are initially disabled.

    Enable custom SQL queries only if you ensure that you follow best practices and implement user read/write privileges at the database level using the tools available for your relational database management system.

    You can set the EnableCustomSql property to bTrue or bFalse to explicitly enable or disable custom SQL queries for the current TdxDashboard container.

    Code Examples

    Enable Custom SQL Queries at the Dashboard Container Level

    The following code example configures a TdxBackendDatabaseSQLConnection component and enables custom SQL queries at the TdxDashboard container level:

    uses
      dxDashboard,                           // Declares the TdxDashboard component
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    procedure TMyForm.cxDisplayDesignerButtonClick(Sender: TObject);
    begin
      ADashboard.EnableCustomSql := bTrue; // Enables custom SQL queries at the container level
      dxBackendDatabaseSQLConnection1.Active := False;  // Terminates the current connection (if one exists)
      // Specify a user-friendly data connection name (for end-user dialogs) and a valid connection string:
      dxBackendDatabaseSQLConnection1.DisplayName := 'PostgreSQL Database Connection';
      dxBackendDatabaseSQLConnection1.ConnectionString :=
    
        'XpoProvider=Postgres;' +     // Specifies the database engine type
        'Server=127.0.0.1;' +         // Specifies the database host IP address
        'User ID=myuser;' +           // Specifies a valid user name
        'Password=123;' +             // Specifies the corresponding password for the user name
        'Database=dashboard_test;' +  // Specifies the target database name
        'Encoding=UNICODE';           // Sets UTF-8 as the required encoding
    
      dxBackendDatabaseSQLConnection1.Active := True;   // Connects to the test database
      ADashboard.ShowDesigner;                 // Displays the Dashboard Designer dialog
    end;
    

    Enable Custom SQL Queries Globally at Startup

    The code example demonstrated in this section changes the TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql class property value to True in the initialization section of the main application unit for all TdxDashboard/TdxDashboardControl and TdxReport components in the project.

    Open the Project Source to Edit the Main Function

    To open the main application unit of your project, you can use one of the following options:

    • Select ProjectView Source in the main menu of your RAD Studio IDE.
    • Select the target project in the Projects Window and press Ctrl + V (alternatively, you can display the context menu and select the View Source option).
    uses
      Forms,
      dxBackend.ConnectionString.SQL;  // Declares the TdxBackendDatabaseSQLConnection component
    // ...
    
    begin
      TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql := True;  // Enables custom SQL queries globally
      Application.Initialize;
      Application.MainFormOnTaskBar := True;
      Application.CreateForm(TMyForm, MyForm);
      Application.Run;
    end.
    

    Default Value

    The EnableCustomSql property’s default value is bDefault.

    The default EnableCustomSql property value indicates that the TdxBackendDatabaseSQLConnection.DefaultEnableCustomSql property determines if custom SQL queries are enabled.

    See Also