Widget Events - Figure out the events taking place in your dashboard
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:
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:
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:
Check out this related content:
Academy Course
Sisense Documentation
Published 08-21-2024
Ophir_Buchman
Data Integration
Joined October 19, 2021