Forum Discussion

zach_myt's avatar
zach_myt
Data Pipeline
02-06-2023
Solved

Hide column until drilled into

I want to hide a column until the user drills into the chart. Example of what it currently looks like below:

I would like to hide the "Videos in Module" until the user clicks the drill into. So it would look like this initially.

Then when a user clicks drill into it would look like this:

"Videos in modules" are not always the same count throughout organizations so I am unable to just display the min or max video count.

 

  • Hi zach_myt ,

     Try this widget script: 

    (Disable the column 'Videos in Module' and the script will enable when you drill into. Below script works if 'Videos in Module' is a dimension. Update the line 8 and 17 as mentioned in the comment if 'Videos in Module' is a calculated column.)

    widget.on("buildquery", function (se, ev) { 
    	
    	let columntoShow = 'Videos in Module' 
    	
    	let drilledColumn = ev.query.metadata.find(el=>el.parent)
    	
    	if(drilledColumn){
    		$.each(ev.widget.metadata.panels[0].items, function(index, value){  //use 1 instead of 0 if it is a calculated panel
    			if(value.disabled == true && value.jaql.title == columntoShow) 
    			{ 
    				var newJaql = { 
    					jaql  : JSON.parse(JSON.stringify(value.jaql)) 
    				} 
    				ev.query.metadata.push(newJaql) 
    				lastIndex = ev.query.metadata.length - 1 
    				ev.query.metadata[lastIndex].disabled = false	 
    				ev.query.metadata[lastIndex].panel = 'rows' //use 'measures' if it is a calculated panel
    			} 
    		}) 
    	
    	}
    
    })

    -Hari

     

5 Replies

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

    Hi zach_myt ,

     Try this widget script: 

    (Disable the column 'Videos in Module' and the script will enable when you drill into. Below script works if 'Videos in Module' is a dimension. Update the line 8 and 17 as mentioned in the comment if 'Videos in Module' is a calculated column.)

    widget.on("buildquery", function (se, ev) { 
    	
    	let columntoShow = 'Videos in Module' 
    	
    	let drilledColumn = ev.query.metadata.find(el=>el.parent)
    	
    	if(drilledColumn){
    		$.each(ev.widget.metadata.panels[0].items, function(index, value){  //use 1 instead of 0 if it is a calculated panel
    			if(value.disabled == true && value.jaql.title == columntoShow) 
    			{ 
    				var newJaql = { 
    					jaql  : JSON.parse(JSON.stringify(value.jaql)) 
    				} 
    				ev.query.metadata.push(newJaql) 
    				lastIndex = ev.query.metadata.length - 1 
    				ev.query.metadata[lastIndex].disabled = false	 
    				ev.query.metadata[lastIndex].panel = 'rows' //use 'measures' if it is a calculated panel
    			} 
    		}) 
    	
    	}
    
    })

    -Hari

     

    • zach_myt's avatar
      zach_myt
      Data Pipeline

      Hi Hari,

      This script makes sense but it isn't affecting my widget at all. I saved it in edit script window, refreshed, drilled down but it is same behavior with 'Videos in Module' not displaying on drill down. I am fairly new to Sisense, is there a way I can debug this to step through and see what is happening?  Or do you have any other suggestions?

    • zach_myt's avatar
      zach_myt
      Data Pipeline

      Hari, this works now! Looks like I had a typo in column on one of my widgets. Thank you for this, its perfect!

  • Hi zach_myt ,

    What you are actually looking to achieve is interactiveness when using table\pivot widgets.
    You might be interested in a stable code-free solution which is the "Control Table Columns" or the "Expandable Pivot "by Paldi solutions.

    With those plugins, viewers get expand\collapse capability and can decide which columns they want to see and which they want to hide.

    Let me know if you would like to trial those plugins and feel free to reach out of you have any further questions, we're always happy to help (: 

     

    Paldi Solutions - Number #1 Sisense Plugins Developer 
  • zach_myt's avatar
    zach_myt
    Data Pipeline

    I am really looking for something that doesn't require a plugin. Is there some type of work around that can accomplish the same type of functionality?