Skip to content

DevExpress-Examples/winforms-dashboard-pass-hidden-dashboard-parameters-to-custom-sql-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dashboard for WinForms - How to Pass a Hidden Dashboard Parameter to a Custom SQL query

This example shows how to pass a hidden dashboard parameter to a custom SQL query. In this example, the DashboardViewer.CustomParameters event is handled to change the dashboard parameter's default value before it is passed to the query.

Example Overview

To pass a hidden dashboard parameter to a custom SQL query, do the following.

Create a Dashboard Parameter

In the Dashboard Designer, create a dashboard parameter.

Click the Parameters button from the Dashboard page group on the Ribbon's Home page. Click Add to create a dashboard parameter. Diasble the Visible property to hide the parameter from the Dashboard Parameters dialog. In this example, the dashboard parameter's name is custIDDashboardParameter and its default value is ALFKI:

Dashboard Parameter Settings

Create a Custom Query

Custom SQL queries are disabled by default. To allow users to specify custom SQL queries in the Query Builder/Query Editor, set the SqlWizardSettings.EnableCustomSql property exposed by the DashboardDataSourceWizardSettings class to true. Add the following code to allow custom SQL queries:

dashboardDesigner1.DataSourceWizard.SqlWizardSettings.EnableCustomSql = true;

Specify the query in the SQL string editor in the Query Builder/Query Editor:

Custom SQL Query with a Dashboard Parameter

This query contains a query parameter named custIDQueryParameter.

Bind the Query Parameter to the Dashboard Parameter

To change the query parameter value dynamically, bind it to the custIDDashboardParameter dashboard parameter. To do this, on the next page of the Query Editor, click Add to create a query parameter. Specify the parameter settings. In the Name column, specify the name used in the query. Select the Expression check box and bind the query parameter to the dashboard parameter:

Query Parameter Settings

Click Finish.

Change the Default Parameter Value in Code (Dashboard Viewer)

Load the created dashboard to the Dashboard Viewer.

Handle the DashboardViewer.CustomParameters event and specify the value to be passed to the query: Form1.cs (VB: Form1.vb).

As a result, a user sees a dashboard based on the data from the SQL query with the custIDQueryParameter query parameter's value specified in the DashboardViewer.CustomParameters event handler (AROUT).

Dashboard

Files to Review:

Documentation

More Examples