Skip to content

DevExpress-Examples/vcl-dashboards-pass-hidden-parameters-to-custom-sql-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevExpress Dashboards for Delphi/C++Builder — Pass a Hidden Dashboard Parameter to a SQL Query

This example demonstrates a dashboard that displays sales data for a selected country. The selected country is passed to the underlying SQL query as a hidden dashboard parameter. This sample solution uses the TdxCustomDashboardControl.Parameters property to access and modify the target dashboard parameter.

Prerequisites

DevExpress Reports Prerequisites

Implementation Details

The scenario demonstrated in this project relies on a configured dashboard layout shipped with sample source code.

Follow these steps to add a hidden parameter to a dashboard and use the parameter in a SQL query:

Step 1: Create a Dashboard Parameter

  1. Open the DevExpress Dashboard Designer (select the Designer… item from the TdxDashboardControl component's context menu at design time or call the ShowDesigner method in code).

    DevExpress VCL Dashboards — Open the Designer Dialog

  2. Open the dashboard menu and click Parameters.

  3. Create a parameter and configure its settings within the PARAMETERS pane.

  4. Uncheck the Visible check box to hide the parameter in Dashboard Viewer mode.

This sample project creates a hidden parameter named CountryDashboardParameter and sets France as the default value:

DevExpress VCL Dashboards — Add and Configure a Parameter

Step 2: Create a Query

  1. Select Data Sources in the dashboard menu.

  2. Click Add within the DATA SOURCES pane to display the Add Data Source dialog.

  3. Click Create data source… to run the Dashboard Data Source Wizard.

  4. Create a new query as follows:

    DevExpress VCL Dashboards — Use the Query Builder Dialog

Step 3: Bind a Query Parameter to a Dashboard Parameter

  1. Create a new filter within the QUERY PROPERTIES section.

  2. Add a new query parameter named CountryParameter.

  3. Expand the PARAMETERS section.

  4. Switch parameter type to Expression for CountryParameter.

  5. Set the parameter value to CountryDashboardParameter.

    DevExpress VCL Dashboards — Use the Filter Builder Dialog

Step 4: Assign Parameter Values

To modify parameters in a dashboard, assign values to individual Parameters collection members as follows:

Delphi

procedure TMainForm.cbCountriesPropertiesEditValueChanged(Sender: TObject);
begin
  dxDashboardControl1.Parameters['CountryDashboardParameter'].Value := cbCountries.EditValue;
end;

C++

void __fastcall TMainForm::cbCountriesPropertiesEditValueChanged(TObject *Sender)
{
  dxDashboardControl1->Parameters->ParamByName[L"CountryDashboardParameter"]->Value =
      cbCountries->EditValue;
}

Documentation

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)

About

This example demonstrates a dashboard that displays sales data for a selected country. The selected country is passed to the underlying SQL query as a hidden dashboard parameter.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors