Back to Devexpress

StaticListLookUpSettings Class

dashboard-devexpress-dot-dashboardcommon-20f7c37a.md

latest9.3 KB
Original Source

StaticListLookUpSettings Class

Provides the look-up editor settings for dashboard parameters that are not bound to a data source.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class StaticListLookUpSettings :
    ParameterLookUpSettings
vb
Public Class StaticListLookUpSettings
    Inherits ParameterLookUpSettings

Remarks

Use the DashboardParameter.LookUpSettings property to specify the look-up editor settings of the parameter.

Examples

The following example demonstrates how to create a dashboard parameter and pass it to a calculated field‘s expression.

In this example, a new calculated field evaluated at a summary level returns TRUE or FALSE depending on whether the average discount exceeds the selected parameter value.

View Example

csharp
using DevExpress.DashboardCommon;
using DevExpress.XtraEditors;

namespace Dashboard_ParametersAndCalculatedFields
{
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();
            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");
            DashboardSqlDataSource dataSource = (DashboardSqlDataSource)dashboard.DataSources[0];
            GridDashboardItem grid = (GridDashboardItem)dashboard.Items[0];

            // Create a new dashboard parameter.
            StaticListLookUpSettings settings = new StaticListLookUpSettings();
            settings.Values = new string[] { "0.01", "0.05", "0.1" };
            DashboardParameter discountValue = new DashboardParameter("discountValue", 
                typeof(double), 0.05, "Select discount:", true, settings);
            dashboard.Parameters.Add(discountValue);

            // Create a new calculated field and pass the created dashboard parameter 
            // to a calculated field expression.
            CalculatedField isGreater = new CalculatedField();
            isGreater.DataMember = "SalesPerson";
            isGreater.Name = "IsGreater";
            isGreater.Expression = "ToStr(Iif(Avg([Discount]) >= [Parameters.discountValue], 'TRUE', 'FALSE'))";
            dataSource.CalculatedFields.Add(isGreater);

            grid.Columns.Add(new GridMeasureColumn(new Measure("IsGreater")));
            dashboardViewer1.Dashboard = dashboard;
        }
    }
}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.XtraEditors

Namespace Dashboard_ParametersAndCalculatedFields
    Partial Public Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()

            Dim dashboard As New Dashboard()
            dashboard.LoadFromXml("..\..\Data\Dashboard.xml")
            Dim dataSource As DashboardSqlDataSource = DirectCast(dashboard.DataSources(0), DashboardSqlDataSource)
            Dim grid As GridDashboardItem = CType(dashboard.Items(0), GridDashboardItem)

            ' Create a new dashboard parameter.
            Dim settings As New StaticListLookUpSettings()
            settings.Values = New String() { "0.01", "0.05", "0.1" }
            Dim discountValue As New DashboardParameter("discountValue", GetType(Double), 0.05, "Select discount:", True, settings)
            dashboard.Parameters.Add(discountValue)

            ' Create a new calculated field and pass the created dashboard parameter 
            ' to a calculated field expression.
            Dim isGreater As New CalculatedField()
            isGreater.DataMember = "SalesPerson"
            isGreater.Name = "IsGreater"
            isGreater.Expression = "ToStr(Iif(Avg([Discount]) >= [Parameters.discountValue], 'TRUE', 'FALSE'))"
            dataSource.CalculatedFields.Add(isGreater)

            grid.Columns.Add(New GridMeasureColumn(New Measure("IsGreater")))
            dashboardViewer1.Dashboard = dashboard
        End Sub
    End Class
End Namespace

The following example shows how to create a new dashboard parameter and bind it to a custom SQL query parameter in code.

View Example

cs
using DevExpress.DashboardCommon;
using DevExpress.XtraEditors;
using DevExpress.DataAccess;
using DevExpress.DataAccess.Sql;

namespace Dashboard_ParametersAndCustomSQL {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();

            Dashboard dashboard = new Dashboard();
            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            // Creates a new dashboard parameter.
            StaticListLookUpSettings staticSettings = new StaticListLookUpSettings();
            staticSettings.Values = new string[] { "2014", "2015", "2016" };
            DashboardParameter yearParameter = new DashboardParameter("yearParameter", 
                typeof(string), "2015", "Select year:", true, staticSettings);
            dashboard.Parameters.Add(yearParameter);

            DashboardSqlDataSource dataSource = (DashboardSqlDataSource)dashboard.DataSources[0];
            CustomSqlQuery salesPersonQuery = (CustomSqlQuery)dataSource.Queries[0];
            salesPersonQuery.Parameters.Add(new QueryParameter("startDate", typeof(Expression), 
                new Expression("[Parameters.yearParameter] + '/01/01'")));
            salesPersonQuery.Parameters.Add(new QueryParameter("endDate", typeof(Expression), 
                new Expression("[Parameters.yearParameter] + '/12/31'")));
            salesPersonQuery.Sql = 
                "select * from SalesPerson where OrderDate between @startDate and @endDate";

            dashboardViewer1.Dashboard = dashboard;
        }
    }
}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.XtraEditors
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Sql

Namespace Dashboard_ParametersAndCustomSQL
    Partial Public Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()

            Dim dashboard As New Dashboard()
            dashboard.LoadFromXml("..\..\Data\Dashboard.xml")

            ' Creates a new dashboard parameter.
            Dim staticSettings As New StaticListLookUpSettings()
            staticSettings.Values = New String() { "2014", "2015", "2016" }
            Dim yearParameter As New DashboardParameter("yearParameter", GetType(String), "2015", "Select year:", True, staticSettings)
            dashboard.Parameters.Add(yearParameter)

            Dim dataSource As DashboardSqlDataSource = DirectCast(dashboard.DataSources(0), DashboardSqlDataSource)
            Dim salesPersonQuery As CustomSqlQuery = CType(dataSource.Queries(0), CustomSqlQuery)
            salesPersonQuery.Parameters.Add(New QueryParameter("startDate", GetType(Expression), New Expression("[Parameters.yearParameter] + '/01/01'")))
            salesPersonQuery.Parameters.Add(New QueryParameter("endDate", GetType(Expression), New Expression("[Parameters.yearParameter] + '/12/31'")))
            salesPersonQuery.Sql = "select * from SalesPerson where OrderDate between @startDate and @endDate"

            dashboardViewer1.Dashboard = dashboard
        End Sub
    End Class
End Namespace

Inheritance

Object ParameterLookUpSettings StaticListLookUpSettings

See Also

StaticListLookUpSettings Members

LookUpSettings

Create a Dashboard Parameter in the WinForms Designer

DevExpress.DashboardCommon Namespace