cancel
Showing results for 
Search instead for 
Did you mean: 

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

Ophir_Buchman
Sisense Team Member
Sisense Team Member

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_1-1649318307235.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_0-1649316281676.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-1649321821734.png

 

1 REPLY 1

antho686
8 - Cloud Apps
8 - Cloud Apps

Hi   thanks for this script, I'll definitly use it, and it'll be a nice addition to my toolbox 🙂