DashboardParameterDescriptor Class

Contains the parameter settings and metadata.

Namespace: DevExpress.DashboardWin

Assembly: DevExpress.Dashboard.v18.2.Win.dll

Declaration

public class DashboardParameterDescriptor :
    IParameter,
    IFilterParameter
Public Class DashboardParameterDescriptor
    Implements IParameter,
               IFilterParameter

The DashboardParameterDescriptor class members allow you to obtain parameter settings such as the parameter type (the DashboardParameterDescriptor.Type property), the default parameter value (the DashboardParameterDescriptor.DefaultValue property), the parameter name (the DashboardParameterDescriptor.Name), etc.

The DashboardParameterDescriptor.Values property returns possible parameter values. Use the DashboardParameterDescriptor.SelectedValue/DashboardParameterDescriptor.SelectedValues properties to obtain or specify the current parameter values.

The DashboardDesigner and DashboardViewer expose the DashboardDesigner.Parameters / DashboardViewer.Parameters properties that provide access to dashboard parameter settings and metadata.

Examples

The following example demonstrates how to save custom data to a dashboard XML definition using the Dashboard.UserData property.

In this example, current dashboard parameter values are saved to the dashboard XML file. Then, saved values are used to set current parameter values in the loaded dashboard.

using System;
using System.Collections.Generic;
using System.Linq;
using DevExpress.XtraEditors;
using DevExpress.DashboardCommon;
using System.Xml.Linq;
using DevExpress.DashboardWin;

namespace Dashboard_UserData {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
            Dashboard dashboard = new Dashboard();
            dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
        }

        private void btnSaveDashboard_Click(object sender, EventArgs e) {
            Dashboard dashboard = new Dashboard();
            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            // Obtains dashboard parameter settings and metadata for a currently open dashboard.
            IList<DashboardParameterDescriptor> parameters = dashboardViewer1.Parameters;

            // Saves parameter settings and current values to an XML element.
            XElement xml = new XElement("ParametersInfo",
                        from parameter in parameters
                        select new XElement("ParameterInfo",
                                    new XElement("Name", parameter.Name),
                                    new XElement("Value", parameter.Value),
                                    new XElement("Type", parameter.Type)));

            // Adds the created XML element to the dashboard XML definition and saves the dashboard.
            dashboard.UserData = xml;
            dashboard.SaveToXml(@"..\..\Data\Dashboard.xml");
        }

        private void btnLoadDashboard_Click(object sender, EventArgs e) {
            Dashboard dashboard = new Dashboard();
            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            if (dashboard.UserData != null) {
                // Obtains used data from the dashboard XML definition.
                XElement xml = dashboard.UserData;

                // Saves values from the XML element to the list.
                IList<XElement> parsInfo = xml.Elements().ToList();
                IList<object> values = new List<object>();
                foreach (XElement parInfo in parsInfo) {
                    // Converts parameter values with the 'DateTime' type to date-time values.
                    if (parInfo.Element("Type").Value == "DateTime") {
                        values.Add(DateTime.Parse(parInfo.Element("Value").Value));
                    }
                    else {
                        values.Add(parInfo.Element("Value").Value);
                    }
                }

                DashboardParameters parameters1 = dashboardViewer1.Parameters;

                // Sets obtained user values as current parameters' values.
                dashboardViewer1.BeginUpdateParameters();
                for (int i = 0; i < parameters1.Count; i++) {
                    parameters1[i].Value = values[i];
                }
                dashboardViewer1.EndUpdateParameters();
            }
        }
    }
}

Inheritance

Object
DashboardParameterDescriptor

Implements

DevExpress.XtraEditors.Filtering.IFilterParameter
See Also