cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
The example below uses a "peer group" use case, where a company which facilitates customer peer benchmarking, does not want users to compare themselves to fewer than 10 companies.
The first widget, either an indicator or BloX widget, will supply the condition for the dashboard.
When the value is lower than the user-set threshold, all other widgets get hidden.

Base Configuration

Open the Dashboard Script view and paste the following code inside.
Edit the masterWidgetId and threshold variable in the following script:
Dashboard Script Part 1:
//----- Configuration -----------------------------------------------

let masterWidgetId = '<WidgetID here wrapped in single quotes>';
let threshold = <your integer threshold here>;

//-------------------------------------------------------------------------

HOW TO ACCESS THE WIDGETID

You can access the ID by opening a widget's edit mode and taking the id after the widgets/ part inside the URL.
URL: ...dashboards/<DashboardID>/widgets/<WidgetID>/

SETTING THE THRESHOLD

If the value of the indicator or first value in the blox widget is less than the value of your threshold variable, then other widgets of the dashboard will be hidden.

Completing The Script

The next piece of the code depends on which widget type you use.
You can use both Indicator and BloX widget types.

Indicator Widget As Master Widget

If your leading or Master widget is an indicator, paste the following code after the configuration code you pasted earlier.
Dashboard Script Part 2a (for indicator)
let isHidden = 0;

dashboard.on('refreshend', (args, el) => {
 let masterWidget = args.widgets.$$widgets.find(w => w.oid === masterWidgetId);
 let logicValue = masterWidget.queryResult.value.data;
 if (logicValue < threshold){
  $( 'widget' ).not( "[widgetid="+masterWidgetId+"]").slideUp(200);
  isHidden = 1;
 } else {
  if ( isHidden == 1){  
   $('widget').slideDown(200, ()=>{dashboard.refresh();});
   isHidden = 0;
  }
 }
});

BloX As Master Widget

If your leading or Master widget is a BloX widget, paste the following code after the configuration code you pasted earlier.
Dashboard Script Part 2b (for BloX)
let isHidden = 0;

dashboard.on('refreshend', (args, el) => {
 let masterWidget = args.widgets.$$widgets.find(w => w.oid === masterWidgetId);
 let logicValue = masterWidget.queryResult[0][0].Value;
 if (logicValue < threshold){
  $( 'widget' ).not( "[widgetid="+masterWidgetId+"]").slideUp(200);
  isHidden = 1;
 } else {
  if ( isHidden == 1){  
   $('widget').slideDown(200, ()=>{dashboard.refresh();});
   isHidden = 0;
  }
 }
});
Now save the script and refresh the dashboard for the script to take effect.
Enjoy!
Version history
Last update:
‎03-02-2023 09:07 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

Sisense Privacy Policy