Skip to main content

DashboardViewer.SetDashboardState(DashboardState) Method

Applies the dashboard state to the loaded dashboard.

Namespace: DevExpress.DashboardWin

Assembly: DevExpress.Dashboard.v24.1.Win.dll

NuGet Package: DevExpress.Win.Dashboard

Declaration

public void SetDashboardState(
    DashboardState state
)

Parameters

Name Type Description
state DashboardState

A DashboardState object that contains the dashboard state information.

Remarks

View Example: How to Save and Restore the Dashboard State

The following code snippet applies the created dashboard state to the loaded dashboard at runtime:

//...
private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e){
    DashboardToolbarItem resetStateItem = new DashboardToolbarItem("Reset State",
        new Action<DashboardToolbarItemClickEventArgs>((args) =>
        {
            dashboardViewer1.SetDashboardState(CreateDashboardState()); ;
        }));
    resetStateItem.Caption = "Reset Dashboard State";
    e.Items.Add(resetStateItem);
}
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;
}
//...

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetDashboardState(DashboardState) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also