-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
23 lines (21 loc) · 994 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function onBeforeRender(dashboardControl) {
var viewerApi = dashboardControl.findExtension('viewerApi');
if (viewerApi) {
viewerApi.on('itemMasterFilterStateChanged', e => onItemMasterFilterStateChanged(dashboardControl, e));
}
}
function onItemMasterFilterStateChanged(dashboardControl, e) {
if (e.itemName === 'gridDashboardItem1') {
var viewerApi = dashboardControl.findExtension('viewerApi');
var filterValues = viewerApi.getCurrentFilterValues(e.itemName);
if (filterValues) {
var slice = viewerApi.getItemData(e.itemName).getSlice(filterValues[0].getAxisPoint());
var productIdMeasure = slice.getMeasures().filter(m => m.dataMember === 'ProductID')[0];
var productId = slice.getMeasureValue(productIdMeasure.id).getValue();
// Send a ProductId value to the server using Request Headers
dashboardControl.remoteService.headers = { 'ProductId': productId };
// Refresh the Chart Dashboard Item
dashboardControl.refresh(['chartDashboardItem1']);
}
}
}