Forum Discussion

rholmesminton's avatar
rholmesminton
Cloud Apps
06-10-2025

JavaScript does not work for Tabber

I added the following JavaScript to my tabber widget. However it does not execute. I found this JavaScript in a help article on the Sisense Community website. It is designed to change the dashboard filters based on which tab is selected. Can you please tell me what I need to do make this script work?  My work around was to hide the dashboard filter and disabling the dashboard filter on each widget and creating a widget level filter.

 
$('.listDefaultCSS .listItemDefaultCSS', element).on('click', function(s){ 
widget.scriptConfig = true;
    
    filter = prism.activeDashboard.filters.$$items.find(el=>el.jaql.title == 'Checklist Type') //Title of filter
 
    //mapping of Tab name and filter item. Here when Tab1 is selected, 'Onboarding' will get selected in Checklists Type filter
    var tabFilterMapping = {
        'Tab1':"Onboarding",
        'Tab2':"Advancement"
    }
    
    var filterValue = tabFilterMapping[$(s)[0].currentTarget.innerHTML]
 
    filter.jaql.filter = {
        "explicit": true,
        "multiSelection": false,
        "members": [
        filterValue
        ]
    }
    var filterOptions = {
                            save: true,
                            refresh: true,
                        }
 
    
    prism.activeDashboard.filters.update(filter, filterOptions)
 
}) ;
});

 

 

8 Replies

  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi rholmesminton​ ,

    I tried the above script, and it's working well.

    One thing to note: make sure your tab names are correct and that the tab names in the 'tabFilterMapping' variable are in uppercase. This is important because the tabber displayed all tab names in uppercase.

    Here is the updated script:

    
    widget.on('ready', function(w, args){
    		
    	$('.listDefaultCSS .listItemDefaultCSS', element).on('click', function(s){ 
    	widget.scriptConfig = true;
    
    		filter = prism.activeDashboard.filters.$$items.find(el=>el.jaql.title == 'Checklist Type') //Title of filter
    
    		//mapping of Tab name and filter item. Here when Tab1 is selected, 'Onboarding' will get selected in Checklists Type filter
    		var tabFilterMapping = {
    			'TAB 1':"Onboarding",
    			'TAB 2':"Advancement"
    		}
    
    		var filterValue = tabFilterMapping[$(s)[0].currentTarget.innerHTML]
    
    		filter.jaql.filter = {
    			"explicit": true,
    			"multiSelection": false,
    			"members": [
    			filterValue
    			]
    		}
    		var filterOptions = {
    								save: true,
    								refresh: true,
    							}
    
    
    		prism.activeDashboard.filters.update(filter, filterOptions)
    
    	}) ;
    });

    - Hari

    • rholmesminton's avatar
      rholmesminton
      Cloud Apps

      Thank you for the solution. It does not change the displayed filter value. I had to hide the dashboard filter to avoid confusion for the user. It still displays as Include all regardless of which tab on the tabber is selected.

  • Hello rholmesminton​,

    I’m following up to see if the solution offered by harikm007​ worked for you.

    If so, please click the 'Accept as Solution' button on the appropriate post. That way other users with the same questions can find the answer. If not, please let us know so that we can continue to help.

    Thank you.

    • rholmesminton's avatar
      rholmesminton
      Cloud Apps

      It works for the most part. However, the dashboard filter still displays include all.

      • DRay's avatar
        DRay
        Admin

        Gotcha. I'll ping harikm007​ to see if he is able to jump back in, but I'm also reaching out internally to try and get an answer for you.

  • Hello rholmesminton​,

    I’m following up to see if the solution offered by harikm007​ worked for you.

    If so, please click the 'Accept as Solution' button on the appropriate post. That way other users with the same questions can find the answer. If not, please let us know so that we can continue to help.

    Thank you.