ASPxClientDashboardItemSelectionChangedEventArgs Class
Provides data for the ASPxClientDashboard.ItemSelectionChanged / ASPxClientDashboardViewer.ItemSelectionChanged events.
Namespace: DevExpress.DashboardWeb.Scripts
Assembly: DevExpress.Dashboard.v18.2.Web.WebForms.Scripts.dll
Declaration
Remarks
The ASPxClientDashboard.ItemSelectionChanged / ASPxClientDashboardViewer.ItemSelectionChanged events are raised after the selection within the dashboard item is changed. The selection can be changed in the following ways:
- the state of master filter item is changed by an end-user or using the ASPxClientDashboard / ASPxClientDashboardViewer‘s API (for instance, using the ASPxClientDashboardViewer.SetMasterFilter or ASPxClientDashboardViewer.ClearMasterFilter methods);
- changing the selection within the dashboard item for which a custom visual interactivity is provided (using the ASPxClientDashboardViewer.ItemVisualInteractivity event).
The ASPxClientDashboardItemSelectionChangedEventArgs.ItemName property returns the name of dashboard item for which the event was raised. Use the GetCurrentSelection method to obtain currently selected elements.
Example
The Web Dashboard allows you to add a custom interactivity to dashboards using the ASPxClientDashboard.ItemVisualInteractivity event. This example demonstrates the following capabilities.
- The Grid dashboard item allows you to select categories and visualize a corresponding product quantity using the dxBarGauge widget. Note that the hidden ‘Quantity’ measure is used to pass the required values to the client.
- The Chart dashboard item highlights bars corresponding to a hovered argument value.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/aspxdashboard-how-to-add-custom-interactivity-to-a-dashboard-t495562.
var defaultAxis = DashboardDataAxisNames.DefaultAxis,
argumentAxis = DashboardDataAxisNames.ChartArgumentAxis;
function addCustomInteractivity(args) {
if (args.ItemName == "gridDashboardItem1") {
args.SetTargetAxes([defaultAxis]);
args.SetSelectionMode("Multiple");
}
if (args.ItemName == "chartDashboardItem1") {
args.SetTargetAxes([argumentAxis]);
args.EnableHighlighting(true);
}
}
function createControls() {
$('#barGauge').dxBarGauge({
startValue: 0,
endValue: 10000,
values: getAllValues(),
label: {
format: 'fixedPoint',
precision: 0
}
});
}
function applyCurrentSelection(args) {
var quantityValues = [];
if (args.ItemName == "gridDashboardItem1" & args.GetCurrentSelection().length != 0) {
var clientData = webViewer.GetItemData("gridDashboardItem1");
for (var i = 0; i < args.GetCurrentSelection().length; i++) {
var currentTuple = args.GetCurrentSelection()[i],
slice = clientData.GetSlice(currentTuple.GetAxisPoint()),
quantity = (slice.GetMeasureValue(clientData.GetMeasures()[0].Id)).GetValue();
quantityValues.push(quantity);
}
} else {
quantityValues = getAllValues();
}
$('#barGauge').data("dxBarGauge").values(quantityValues);
}
function getAllValues() {
var quantityValues = [],
clientData = webViewer.GetItemData("gridDashboardItem1");
for (var i = 0; i < clientData.GetAxis(defaultAxis).GetPoints().length; i++) {
var slice = clientData.GetSlice(clientData.GetAxis(defaultAxis).GetPoints()[i]),
quantity = (slice.GetMeasureValue(clientData.GetMeasures()[0].Id)).GetValue();
quantityValues.push(quantity);
}
return quantityValues;
}