cancel
Showing results for 
Search instead for 
Did you mean: 
Ophir_Buchman
12 - Data Integration
12 - Data Integration

Widget Events - Figure out the events taking place in your dashboard

While creating your scripts you might run into situations where you'd like to analyze what events take place and determine how to best implement your scripts. The following scripts will allow you to do so by dumping the information into your console window (Developer Tools):

Dumping the Dashboard's Events

Add the following code to your dashboard script:

dashboard.on('initialized', function(dashboard) {
  console.log('Dashboard ' + dashboard.oid + ' - Event "initialized"')
  Object.keys(dashboard.$$events).forEach(keyName => {
    if (keyName.startsWith('widget'))
      dashboard.on(keyName,function(dash,widget) {
        console.log('Dashboard ' + dashboard.oid + ' - Event "' + keyName + '" for widget ' + widget.widget.oid) 
      })
      else
        dashboard.on(keyName,function() {
          console.log('Dashboard ' + dashboard.oid + ' - Event "' + keyName + '"') 
        })
  })
})

Example Output:

Ophir_Buchman_0-1723129045519.png

Dumping A Specific Widget's Events

Add the following code to your widget script:

widget.on('initialized', function(widget) {
  console.log('Widget ' + widget.oid + ' - Event "initialized"')
  Object.keys(widget.$$events).forEach(keyName => widget.on(keyName,function() {
    console.log('Widget ' + widget.oid + ' - Event "' + keyName + '"') 
  }))
})

 Example Output:

Ophir_Buchman_1-1723129080970.png

Dumping both Dashboard and Widget Events

Add the following code to your dashboard script:

dashboard.on('initialized', function(dashboard) {
  console.log('Dashboard ' + dashboard.oid + ' - Event "initialized"')
  Object.keys(dashboard.$$events).forEach(keyName => {
    if (keyName.startsWith('widget')) 
    {
      dashboard.on(keyName,function(dash,widget) {
        console.log('Dashboard ' + dashboard.oid + ' - Event "' + keyName + '" for widget ' + widget.widget.oid) 
      })
    }
    else
    {
      dashboard.on(keyName,function() {
        console.log('Dashboard ' + dashboard.oid + ' - Event "' + keyName + '"') 
      })
    }
  })

  dashboard.widgets.$$widgets.forEach(widget => {
    Object.keys(widget.$$events).forEach(keyName => widget.on(keyName,function() {
      console.log('Widget ' + widget.oid + ' - Event "' + keyName + '"') 
    }))
  })
})

Example Output:

Ophir_Buchman_2-1723129113907.png

 

Check out this related content: 

Academy Course

Sisense Documentation 

Rate this article:
Version history
Last update:
‎08-21-2024 07:40 AM
Updated by: