iccube-reporting

Custom Calendar widget, how to consume an event?


I've created a calendar widget like the one in the livedemo - Widget Template - Filter / Fire Event (https://www.iccube.com/livedemo/?ic3Report=%2Fshared%2FLive+Demo%2F3+-+How+to%2FWidget+Template+-+Filter+%252F+Event).

Now I want to use an event from another widget e.g. a button to set the current date. I've configured the widget with the do Set Selection event in the Events configuration: Events Configuration

But when I trigger that event by pushing the button, nothing happens and a error is shown in the notifications-box: error in the notifications-box

The browsers console also shows an error:

12:32:29.929 [Widget (consumeEventHook)][w1] Unexpected identifier

What do I wrong and how do I make this work?


Solution

  • Niels, sorry there is a bug in the reporting (the fix will be available in the next release). Here is an example of the on-consume-event function:

    /**
     * type  - consumed event type,
     * event - consumed event object
     * 
     * Function may return false, to stop event processing
     */
    
        function(context, type, event) {
            switch(type){
                case 'ic3doSetSelection':      
                    var w = $('#reportrange');
                    var d = w.data('daterangepicker');            
    
                    d.setStartDate('03/01/2016');
                    d.setEndDate('03/31/2016');
    
                    break;
           }
        }
    

    Hope this helps.