Skip to main content

DashboardDesigner.SetDashboardState(DashboardState) Method

Applies the dashboard state to the loaded dashboard.

Namespace: DevExpress.DashboardWin

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

Declaration

public void SetDashboardState(
    DashboardState state
)

Parameters

Name Type Description
state DashboardState

A DashboardState object that contains the dashboard state information.

Remarks

Refer to the Manage Dashboard State document for more information about a dashboard state.

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

//...
private void DashboardDesigner1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e){
    DashboardToolbarItem resetStateItem = new DashboardToolbarItem("Reset State",
        new Action<DashboardToolbarItemClickEventArgs>((args) =>
        {
            dashboardDesigner1.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;
}
//...
See Also