Manage Dashboard State
- 3 minutes to read
A dashboard state describes the changes resulting from end-user interaction. The dashboard state is the DashboardState class instance and can contain the following objects:
Dashboard State Object | API |
---|---|
Selected master filter values for dashboard items. | |
Current drill-down levels for dashboard items. | |
Selected Range Filter interval. | |
Selected dashboard item layers for the following items: | |
A selected tab page. | |
Dashboard parameter values. |
Use the DashboardState.Items property to get access to the dashboard item state collection.
The DashboardDesigner provides the following API to manage the dashboard state:
Member | Description |
---|---|
DashboardDesigner.GetDashboardState | Gets the current dashboard state. |
DashboardDesigner.SetDashboardState | Applies the dashboard state to the loaded dashboard. |
DashboardDesigner.SetInitialDashboardState | Allows you to specify the initial dashboard state when loading a dashboard. |
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;
}