Skip to main content
A newer version of this page is available. .

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.

DashboardItemState.MasterFilterValues

Current drill-down levels for dashboard items.

DashboardItemState.DrillDownValues

Selected Range Filter interval.

DashboardItemState.RangeFilterState

Selected dashboard item layers for the following items:

DashboardItemState.SelectedLayerIndex

A selected tab page.

DashboardItemState.TabPageName

Dashboard parameter values.

DashboardState.Parameters

Use the DashboardState.Items property to get access to the dashboard item state collection.

The DashboardViewer provides the following API to manage the dashboard state:

Member Description
DashboardViewer.GetDashboardState Gets the current dashboard state.
DashboardViewer.SetDashboardState Applies the dashboard state to the loaded dashboard.
DashboardViewer.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;
}
See Also