Forum Discussion

Astroraf's avatar
Astroraf
Data Pipeline
08-09-2024
Solved

Can I remove a predefined filter in Sisense

Am I able to remove a predefined filter within Sisense that would disallow my viewers from choosing this option? I am using a date filter and the options in the date filter are Last, This, and Next. I want to be able to remove the Last but keep the This and Next filters as options for my viewers. 

 

DRay  intapiuser 

  • Hi Astroraf ,

    Can you try the following?

    
            prism.on('dashboardloaded', (args, dash) => {
    			const elem = document.createElement('style')
            	elem.innerText = `.gsoNqAmwurDnBIjywenH:nth-child(1) { display: none; }`
                document.head.appendChild(elem)
    
            })

    This removes the 'Last' item by hiding the associated container in CSS.

    It works on my side L2024.1 - but would be mindful to check if any changes to the class name in future (should include in any future version upgrade regression testing in case you need to change the reference).

    Result:

    Thanks,

    Daniel

    RAPID BI

    [email protected]

    RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

     

7 Replies

  • Astroraf's avatar
    Astroraf
    Data Pipeline

    rapidbisupport Thank you so much for the answer. Can you explain what the code is doing for some of us who aren't as tech-savvy with CSS?

    • rapidbisupport's avatar
      rapidbisupport
      Data Pipeline

      Sure thing Astroraf ,

      Please see comments below:

      // when a dashboard is loaded in the application (prism is Sisense application, and dashboardloaded is the event we are hooking into)
              prism.on('dashboardloaded', (args, dash) => {
      // let's create a 'style' object - the kind that normally lives in the head of a document like <style> STYLE GOES HERE </style>
      			const elem = document.createElement('style')
      // The contents of the style uses a selector asking for the first child of the 'gsoNqAmwurDnBIjywenH' class, we want to set it's display property to none.
              	elem.innerText = `.gsoNqAmwurDnBIjywenH:nth-child(1) { display: none; }`
      // we then append the style object we created to the head in the document
                  document.head.appendChild(elem)
      
              })

       you can see these elements in the inspection panel in your browser:

      This will give you an idea of the classes, ids, elements you can play with.

      The other approach here is to use jQuery to manipulate the elements - but there are drawbacks here like that the element needs to exist when the jQuery runs.

      You can try this in your console by doing this:

      $('..gsoNqAmwurDnBIjywenH:nth-child(1)').hide()

      If you run this in your browser console with the Last / This / Next selection open it will hide the Last option.

      Hope this helps?

      Thanks,

      Daniel

      RAPID BI

      [email protected]

      RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

      • Astroraf's avatar
        Astroraf
        Data Pipeline

        So now I would like to remove these three filters. Utilizing your code would my code snippet be:

          prism.on('dashboardloaded', (args, dash) => {
        			const elem = document.createElement('style')
                	elem.innerText = `.gsoNqAmwurDnBIjywenH:nth-child(1) { display: none; }`
                    document.head.appendChild(elem),
                            const elem = document.createElement('style')
                	elem.innerText = `.HaPIPCLdFZZA6Wn8q1V:nth-child(3) { display: none; }`
                    document.head.appendChild(elem)
        
        
        
                })

        or since this element is of a div class then how would I change the code to reflect this?

         

         

  • Hi Astroraf ,

    HaPIPCLdFZZA6Wn8q1VU looks like the class for the divs that contain these controls.

    prism.on('dashboardloaded', (args, dash) => {
    	const elem = document.createElement('style')
    	elem.innerText = `
    	.gsoNqAmwurDnBIjywenH:nth-child(1) { 
    		display: none; 
    	}
    	.HaPIPCLdFZZA6Wn8q1VU:nth-child(3) {
    		display: none;
    	}
    	.HaPIPCLdFZZA6Wn8q1VU:nth-child(4) {
    		display: none;
    	}
    	`
    	document.head.appendChild(elem)
    })

    Try this one out and let me know how you go?

    Daniel

    RAPID BI

    [email protected]

    RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

  • HamzaJ's avatar
    HamzaJ
    Data Integration

    Hey Astroraf ,

    I dont think this is possible. However you could use Blox to create buttons that do exactly this. You can then lock that filter so users cannot change it, except for with the predefined filters in the Blox buttons. --> https://community.sisense.com/t5/knowledge/blox-filter-buttons-for-trailing-x-months/ta-p/8649

    Here is a link to a post explaining this. If you are looking for a easier way then I can recommend Ravid_PaldiTeam 's date range filter https://www.paldi.solutions/plugins/date-range-filter

    Hamza

  • Hi Astroraf ,

    Can you try the following?

    
            prism.on('dashboardloaded', (args, dash) => {
    			const elem = document.createElement('style')
            	elem.innerText = `.gsoNqAmwurDnBIjywenH:nth-child(1) { display: none; }`
                document.head.appendChild(elem)
    
            })

    This removes the 'Last' item by hiding the associated container in CSS.

    It works on my side L2024.1 - but would be mindful to check if any changes to the class name in future (should include in any future version upgrade regression testing in case you need to change the reference).

    Result:

    Thanks,

    Daniel

    RAPID BI

    [email protected]

    RAPID BI - Sisense Professional Services | Implementations | Custom Add-ons

     

    • Astroraf's avatar
      Astroraf
      Data Pipeline

      rapidbisupport the reason I ask, is that my client is asking about how to remove the bottom three filter options to present to their clients.