Skip to main content

Load a Dashboard in ASP.NET MVC

  • 2 minutes to read

Load a Dashboard on the Server

Dashboard storage is a location of dashboards you use in your Web Dashboard application. Users can save new dashboards to this storage and open existing dashboards. You can use the following API to manage dashboards in dashboard storage:

DashboardExtensionSettings.InitialDashboardId
Gets or sets the identifier of the dashboard to be loaded to the ASP.NET MVC Dashboard extension.
DashboardExtensionSettings.LoadDefaultDashboard
Gets or sets whether the default dashboard should be loaded from the dashboard storage.

The DashboardInMemoryStorage and DashboardFileStorage classes implement the IDashboardStorage interface. Cast a corresponding object to IDashboardStorage and use IDashboardStorage.GetAvailableDashboardsInfo to obtain available dashboard identifiers.

The code snippet shows how to specify the SalesDetails dashboard as a default when you configure the control.

<div style="position: absolute; left: 0; right: 0; top:40px; bottom:0;">
    @Html.DevExpress().Dashboard(settings => {
    settings.Name = "webDashboard";
    settings.ControllerName = "DefaultDashboard";
    settings.Width = Unit.Percentage(100);
    settings.Height = Unit.Percentage(100);
    settings.InitialDashboardId = "SalesDetails";
}).GetHtml()
</div>

Load a Dashboard on the Client

DashboardControl.loadDashboard
Use this method to load a dashboard with the specified identifier from the dashboard storage.
DashboardControl.unloadDashboard
Call this method to close the displayed dashboard.
DashboardControlOptions.initialDashboardId
Use this property to specify the identifier of the dashboard to be loaded to the DashboardControl before the control is rendered.

The following code snippet demonstrates how to load a dashboard with the dashboard1 identifier on the client:

dashboardControl.loadDashboard("dashboard1")
    .done(function () { alert("A dashboard is loaded successfully."); })
    .fail(function() { alert("Cannot load a dashboard."); });