In order to refresh all widgets in a dashboard, we need to refresh the entire page. But we can add a button to refresh all widgets.
Here is a script to add refresh button for a dashboard.
Steps:
Create dashboard
Add below script to dashboard
Save the script and refresh the dashboard
dashboard.on('initialized', function (se, ev) {
let dashboardRefreshButton =
`<button id="dashboard-refresh-button"title="Refresh" class = "btn js--btn-action" style="width: 34px; height:28px">
↻
</button>`
let $toolbarRight = $('.prism-toolbar__section--right .prism-toolbar__cell.btns-holder');
$toolbarRight.prepend(dashboardRefreshButton);
$toolbarRight.find('#dashboard-refresh-button').on('click', dashboardRefresh);
})
function dashboardRefresh() {
$.each(dashboard.widgets.$$widgets, function(index, value){
value.refresh()
})
}
Comments