DashboardViewer.DashboardStateChanged Event
Occurs after the current dashboard state in the DashboardViewer is changed.
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v24.2.Win.dll
Declaration
Event Data
The DashboardStateChanged event's data class is DashboardStateChangedEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
DashboardState | Gets the current state of the dashboard. |
Remarks
A dashboard state contains the selected master filter values, current drill-down levels, Range Filter and Date Filter settings, dashboard item layers and current parameter values. Use the DashboardStateChanged event to get the actual dashboard state - the latest interaction changes a user made to a dashboard. The DashboardState property provides access to the states of individual dashboard items displayed in the dashboard.
You can use the DashboardViewer.SetInitialDashboardState event to apply the state when a dashboard is loaded.
For more information about a dashboard state, see Manage Dashboard State.
Example
The following code snippet demonstrates how to save a dashboard state each time it is changed.
The DashboardViewer.GetDashboardState method obtains a dashboard’s state object in the DashboardStateChanged
event that is handled each time the dashboard state is changed. The state is serialized to XML and added to the XElement object stored in the CustomProperties collection.
The dashboard state is restored in the DashboardViewer.SetInitialDashboardState event handler.
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
// ...
DashboardState state = new DashboardState();
const string path = @"..\..\Dashboards\dashboard1.xml";
// ...
private void DashboardViewer_DashboardStateChanged(object sender, DashboardStateChangedEventArgs e) {
state = dashboardViewer.GetDashboardState();
var stateValue = state.SaveToXml().ToString(SaveOptions.DisableFormatting);
dashboardViewer.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);
}
private void DashboardViewer_SetInitialDashboardState(object sender, SetInitialDashboardStateEventArgs e) {
e.InitialState = state;
}
// ...