Skip to main content

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.v23.2.Core.dll

NuGet Package: DevExpress.Dashboard.Core

Declaration

public class DashboardState

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.

API

Server-side

ASPxDashboard.InitialDashboardState / DashboardExtensionSettings.InitialDashboardState

ASPxDashboard.SetInitialDashboardState

DashboardConfigurator.SetDashboardStateService

ASPxDashboard.IncludeDashboardStateToUrl / DashboardExtensionSettings.IncludeDashboardStateToUrl

Client-side

ASPxClientDashboard.GetDashboardState

ASPxClientDashboard.SetDashboardState

ASPxClientDashboard.DashboardStateChanged

DashboardControl.getDashboardState

DashboardControl.setDashboardState(dashboardState)

DashboardControlOptions.onDashboardStateChanged

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:

View Example: How to specify a default dashboard state in code (ASP.NET 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.

View Example: How to Set the Initial 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

View Example: How to Save and Restore the Dashboard State

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;
}

Inheritance

Object
DashboardState
See Also