Search code examples
javascriptwidgeticcubeiccube-reporting

How to Do selection in a widget based on a selection done in a Template widget (JS triggered)


in iccube v6 reporting, I have a Template widget called « Map » hereafter that has some code that triggers an event : Code inside the "Map, Options, After Render" :

self.fireEvent(vizEventType.onSelection, new viz.event.SetSelectionEvent(members));

enter image description here

code inside JS, On Send Event :

function(context, $box, type, args) {
    context.fireEvent("MapZoneSelected",args)
    return args;
}

enter image description here

In the Report JS :

function consumeEvent( context, event ) {                                
if (event.name == 'MapZoneSelected') {
    var mapZoneSelected = event.value; // Just used to debug the passed values
} 
}      

enter image description here

So, I see the MapZoneSelected event is well triggered…

In the Destination widget, do Set Selection is defined to MapZoneSelected But the widget doesn’t set it’s selection according to that event… there is a reaction, but it only clears any previous selection.

I can't figure out where I'm wrong...


Solution

  • I've created an example report for you with the widget template that sends selection events to the chart widget. Just click on bubbles and you will see selection applied on the chart widget(multisiection supported). You could test it here:

    https://demo6.iccube.com/icCube/doc/ic3report?ic3demo=&name=%2Fshared%2FStackOverflow%2FWidget%20Template%20Fire%20Selection&menu=on