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.v24.2.Core.dll
NuGet Package: DevExpress.Dashboard.Core
#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).
#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 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
#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.
#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
The following code snippet shows how to create a dashboard state 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;
}