Forum Discussion

ankitvijay's avatar
ankitvijay
Cloud Apps
02-18-2022
Solved

Setting default filters through iframe query or disable "reset to default filter option"

Hi team.

We are loading the sisense dashboard through an iframe, and we are passing filters as query parameters in the iframe URL as mentioned here https://sisense.dev/guides/embedding/iframe.html#_5-appending-filters

We are looking to achieve either of the following:

 

  • If it is not possible, can we read filters passed from the iframe query in "Edit script" and set those filters as default filter instead? 

 

  • Hi harikm007,

    Thanks for your response. This code worked. However, instead of selecting the button by title, I went for a slightly different approach by removing the siblings of the filter filter-title class. I also removed the "Restore" and "Add filter" icons explicitly, as I could see these icons flashed for a millisecond on load before getting removed. My overall code looks like below:

     

    dashboard.on('initialized', function(se, ev){
    	se.userAuth.dashboards.filters.set_defaults = false;	
     	$('#general-restore-usage').remove();
    	$('#general-plus').remove();	
    })
    
    dashboard.on('refreshstart', function(se, ev){
    	// Remove the restore button
    	$('.filters-title').siblings().remove()
    })

     

    Hope it can help others.

4 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    ankitvijay ,

    This dashboard script will hide 'Restore my default filters' icon. I tested it in Sisense dashboard. Please check if it works in your iFrame as well.

    dashboard.on('initialized', function(se, ev){
    	$('#prism-rightview .global-filters .filters-headline .fl-icon-container').remove()
    })

    -Hari

     

    • ankitvijay's avatar
      ankitvijay
      Cloud Apps

      HI harikm007 ,

      Thanks for your response.

      I tried to use the above code. But unfortunately, it does not seem to be working. If it helps here is the reset filter button element I see.

      <button class="btn btn--icon btn--dark btn--on-grey enabled" title="Restore my default filters " data-ng-click="resetFilters()" data-ng-show="dashboard.defaultFilters" data-ng-disabled="!isFilterDifferentFromDefault()" data-ng-class="{'enabled': isFilterDifferentFromDefault()}"> <svg class="svg-i"> <use xlink:href="#general-restore-usage"></use> </svg> </button>
      

      I was able to hide the icon using the below code but the invisible button is still there. Is there a better way to identify and remove the button?

      $('#general-restore-usage').remove();

       

      • harikm007's avatar
        harikm007
        Data Warehouse

        ankitvijay ,

        Not sure why HTML classes are different in my view. But please try this script (this is based on the html you posted above)

         

        dashboard.on('refreshstart', function(se, ev){
        	$('button[title="Restore my default filters "]').remove()
        })

         

        -Hari