DashboardState Class
A data container for changes resulting from end-user interaction - selected master filter values, drill-down levels, selected dashboard item layers and current parameter values.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v18.2.Core.dll
Declaration
Related API Members
The following members return DashboardState objects:
Remarks
The DashboardState class includes states of individual dashboard items (the DashboardState.Items property) and currently selected parameter values (DashboardState.Parameters).
See the details about the platform specifics below:
DashboardState in ASP.NET
The table below lists main server-side and client-side API members related to obtaining and setting a dashboard state.
Note that on the client side, a dashboard state is represented by a JSON object, that can be used to initialize DashboardState using the DashboardStateExtensions.LoadFromJson extension method. To save the current DashboardState to JSON, use DashboardStateExtensions.SaveToJson.
You can also apply a specified dashboard state when performing server-side exporting using methods exposed by the ASPxDashboardExporter, for instance:
- WebDashboardExporter.ExportToPdf / WebDashboardExporter.ExportDashboardItemToPdf
- WebDashboardExporter.ExportToImage / WebDashboardExporter.ExportDashboardItemToImage
- WebDashboardExporter.ExportToExcel / WebDashboardExporter.ExportDashboardItemToExcel
The sample illustrates how to specify a dashboard state (such as master filter or parameter values) in code and how to apply this state when loading a dashboard for the first time. In this example, the DashboardState
object holds the required dashboard state. The ASPxDashboard.SetInitialDashboardState event is used to apply the specified dashboard state when loading a dashboard.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/aspxdashboard-how-to-specify-a-default-dashboard-state-in-code-t513681.
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System;
using System.Collections.Generic;
namespace WebDashboard_ManualDashboardState
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
}
protected void ASPxDashboard1_SetInitialDashboardState(object sender, SetInitialDashboardStateEventArgs e) {
e.InitialState = InitializeDashboardState();
}
public DashboardState InitializeDashboardState() {
DashboardState dashboardState = new DashboardState();
DashboardParameterState parameterState =
new DashboardParameterState("countryParameter", "USA", typeof(string));
DashboardItemState gridFilterState = new DashboardItemState("gridDashboardItem1");
gridFilterState.MasterFilterValues.AddRange(new List<object[]>() {
new string[1] { "Andrew Fuller" },
new string[1] { "Laura Callahan" }
}
);
DashboardItemState treemapDrilldownState = new DashboardItemState("treemapDashboardItem1");
treemapDrilldownState.DrillDownValues.Add("Beverages");
DashboardItemState rangeFilterState = new DashboardItemState("rangeFilterDashboardItem1");
rangeFilterState.RangeFilterState.Selection =
new RangeFilterSelection(new DateTime(2015, 1, 1), new DateTime(2016, 1, 1));
dashboardState.Parameters.Add(parameterState);
dashboardState.Items.AddRange(new List<DashboardItemState>() {
gridFilterState,
treemapDrilldownState,
rangeFilterState }
);
return dashboardState;
}
}
}
To learn more about a dashboard state, see Manage Dashboard State.
DashboardState in WPF
Use the GetDashboardState() and SetDashboardState(DashboardState) methods to obtain and apply the dashboard state, respectively.
To restore the previously saved dashboard state, handle the SetInitialDashboardState event.
For more information. refer to the Manage Dashboard State article.