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. S...
  • harikm007's avatar
    02-10-2023

    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