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.
DevExpress Reports Prerequisites
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:
- Create a Dashboard Parameter
- Create a SQL Query
- Bind a Query Parameter to a Dashboard Parameter
- Load Parameters From Layout
- Assign Parameter Values
-
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).
-
Open the dashboard menu and click Parameters.
-
Create a parameter and configure its settings within the PARAMETERS pane.
-
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:
-
Select Data Sources in the dashboard menu.
-
Click Add within the DATA SOURCES pane to display the Add Data Source dialog.
-
Click Create data source… to run the Dashboard Data Source Wizard.
-
Create a new query as follows:
-
Create a new filter within the QUERY PROPERTIES section.
-
Add a new query parameter named CountryParameter.
-
Expand the PARAMETERS section.
-
Switch parameter type to
Expressionfor CountryParameter. -
Set the parameter value to
CountryDashboardParameter.
The Parameters collection is initially empty. You need to populate the collection at design- or runtime on demand.
To populate the collection with parameters from a dashboard layout definition, call the Parameters.LoadFromLayout procedure at runtime.
dxDashboardControl1.Parameters.LoadFromLayout;dxDashboardControl1->Parameters->LoadFromLayout();Select Load Parameters from Dashboard from the TdxDashboardControl context menu at design time:
To modify parameters in a dashboard, assign values to individual Parameters collection members as follows:
procedure TMainForm.cbCountriesPropertiesEditValueChanged(Sender: TObject);
begin
dxDashboardControl1.Parameters['CountryDashboardParameter'].Value := cbCountries.EditValue;
end;void __fastcall TMainForm::cbCountriesPropertiesEditValueChanged(TObject *Sender)
{
dxDashboardControl1->Parameters->ParamByName[L"CountryDashboardParameter"]->Value =
cbCountries->EditValue;
}- Introduction to DevExpress VCL Dashboards
- Get Started: Create a Dashboard Using the Designer Dialog
- Use Query Parameters
- Dashboard Parameters
- DevExpress VCL Dashboards Prerequisites
- API reference:
(you will be redirected to DevExpress.com to submit your response)




