Back to Devexpress

DashboardConfigurator Class

dashboard-devexpress-dot-dashboardweb.md

latest9.1 KB
Original Source

DashboardConfigurator Class

Provides a server side API for the ASP.NET Core Dashboard control, ASP.NET Web Forms Dashboard control, and ASP.NET MVC Dashboard extension.

Namespace : DevExpress.DashboardWeb

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

NuGet Package : DevExpress.Web.Dashboard.Common

Declaration

csharp
public class DashboardConfigurator :
    DashboardConfiguratorBase,
    IDashboardServiceProvider,
    IDataSourceCacheEventsProvider,
    IDashboardCustomizationProvider,
    IClientTrustLevelVerification,
    IDataSourceWizardCustomizationProvider
vb
Public Class DashboardConfigurator
    Inherits DashboardConfiguratorBase
    Implements IDashboardServiceProvider,
               IDataSourceCacheEventsProvider,
               IDashboardCustomizationProvider,
               IClientTrustLevelVerification,
               IDataSourceWizardCustomizationProvider

The following members return DashboardConfigurator objects:

Remarks

Important

For information on how to use the DashboardConfigurator‘s API, see the following topic: Dashboard Backend

To prepare the dashboard control for the first use, you need to create dashboard and data source storages.

  1. Use the static DashboardConfigurator.SetDashboardStorage method to create a storage that will contain dashboards. You can use predefined dashboard storages (DashboardFileStorage or DashboardInMemoryStorage) or you can implement the IDashboardStorage interface to provide your own logic for managing dashboards.

Note

The DashboardConfigurator uses the DashboardInMemoryStorage if you do not create the dashboard storage.

  1. Prepare data sources that will be used to supply dashboards with data. You can do this in two ways.

The DashboardConfigurator class also exposes an API used to supply the dashboard with data at runtime (for instance, using the DashboardConfigurator.ConfigureDataConnection or DashboardConfigurator.DataLoading events).

The following example shows how to set up ASPxDashboard with the DashboardConfigurator settings.

Set the UseDashboardConfigurator property to true and use the DashboardConfigurator to process data-related operations and handle data-related events (set the dashboard /data source storage, specify a connection provider, etc).

html
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebFormsDashboardConfigurator.Default" %>

<%@ Register Assembly="DevExpress.Web.v18.2, Version=18.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Dashboard.v18.2.Web.WebForms, Version=18.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Web Dashboard</title>
</head>
<body>
    <form id="form1" runat="server">
        <div style="position: absolute; left: 0; right: 0; top:0; bottom:0;">
            <dx:ASPxDashboard ID="ASPxDashboard1" runat="server" Width="100%" Height="100%" ClientInstanceName="webDashboard">
            </dx:ASPxDashboard>
        </div>
    </form>
</body>
</html>
csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebFormsDashboardConfigurator
{
    public partial class Default : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
            ASPxDashboard1.UseDashboardConfigurator = true;
        }
    }
}
csharp
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Excel;
using DevExpress.DataAccess.Web;
using System;

namespace WebFormsDashboardConfigurator
{
    public class Global : System.Web.HttpApplication {

        protected void Application_Start(object sender, EventArgs e) {
            DashboardConfigurator.Default.SetDashboardStorage(new DashboardFileStorage(Server.MapPath("App_Data/Dashboards")));
            DashboardConfigurator.Default.SetDataSourceStorage(CreateDataSourceStorage());
            DashboardConfigurator.Default.SetConnectionStringsProvider(new ConfigFileConnectionStringsProvider());
            DashboardConfigurator.Default.ConfigureDataConnection += Default_ConfigureDataConnection;
        }

        public DataSourceInMemoryStorage CreateDataSourceStorage()
        {
            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

            // Registers an OLAP data source.
            DashboardOlapDataSource olapDataSource = new DashboardOlapDataSource("OLAP Data Source", "olapConnection");
            DashboardOlapDataSource.OlapDataProvider = OlapDataProviderType.Xmla;
            dataSourceStorage.RegisterDataSource("olapDataSource", olapDataSource.SaveToXml());

            // Registers an Excel data source.
            DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");
            excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
            dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());

            return dataSourceStorage;
        }

        private void Default_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
            if (e.ConnectionName == "olapConnection") {
                OlapConnectionParameters olapParams = new OlapConnectionParameters();
                olapParams.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;"
                    + "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;";
                e.ConnectionParameters = olapParams;
            }
            if (e.DataSourceName == "Excel Data Source") {
                ExcelDataSourceConnectionParameters excelParams = new ExcelDataSourceConnectionParameters(HttpContext.Current.Server.MapPath("App_Data/Sales.xlsx"));
                e.ConnectionParameters = excelParams;
            }
        }

        protected void Session_Start(object sender, EventArgs e) {

        }

        protected void Application_BeginRequest(object sender, EventArgs e) {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e) {

        }

        protected void Application_Error(object sender, EventArgs e) {

        }

        protected void Session_End(object sender, EventArgs e) {

        }

        protected void Application_End(object sender, EventArgs e) {

        }
    }
}

Inheritance

Object DashboardConfiguratorBase DashboardConfigurator BlazorDashboardConfigurator

See Also

DashboardConfigurator Members

DevExpress.DashboardWeb Namespace