DashboardState Class
A data container for changes resulting from end-user interaction - selected master filter values, drill-down levels, Range Filter settings, dashboard item layers and current parameter values.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v19.2.Core.dll
Declaration
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
Example: How to: Specify a Default Dashboard State in Code (Web Forms)
DashboardState in WPF
Use the DashboardControl.GetDashboardState and DashboardControl.SetDashboardState methods to obtain and apply the dashboard state, respectively.
Handle the DashboardControl.SetInitialDashboardState event to restore the saved dashboard state.
Example: How to: Save and Restore the Dashboard State (WPF)
DashboardState in WinForms
Use the DashboardDesigner.GetDashboardState and DashboardDesigner.SetDashboardState methods to obtain and apply the dashboard state, respectively.
Handle the DashboardDesigner.SetInitialDashboardState event to restore the saved dashboard state.
Example
Note
The complete sample project How to Save and Restore the Dashboard State is available in the DevExpress Examples repository.
The following code snippet shows how to create a dashboard state for in code:
public DashboardState CreateDashboardState()
{
DashboardState state = new DashboardState();
// Set a range for a Range Filter.
state.Items.Add(new DashboardItemState("rangeFilterDashboardItem1")
{
RangeFilterState = new RangeFilterState(
new RangeFilterSelection(
new DateTime(2015, 1, 1), new DateTime(2017, 1, 1)))
});
// Specify master filter and drill-down values.
state.Items.Add(new DashboardItemState("gridDashboardItem1")
{
MasterFilterValues = new List<object[]>() {
new object[] { "Gravad lax" },
new object[] { "Ikura" } },
DrillDownValues = new List<object>() { "Seafood" }
});
// Set a dashboard item layer.
state.Items.Add(new DashboardItemState("treemapDashboardItem1")
{
SelectedLayerIndex = 1
});
// Specify a default tab page.
state.Items.Add(new DashboardItemState("tabContainerDashboardItem1")
{
TabPageName = "dashboardTabPage2"
});
// Define a dashboard parameter value.
state.Parameters.Add(new DashboardParameterState()
{
Name = "ParameterCountry",
Value = "UK",
Type = typeof(string)
});
return state;
}