top of page

Hide a Column from Table Widget

Sometimes we may need to hide a column from table widget, so that it will appear only in the downloaded CSV file. Here is a solution to achieve this.


Steps:

  1. Create a table widget

  2. Add below widget script. Update the variable columnIndex with index of column to be hidden. (index is a number assigned to columns starting with 1. In above screenshot, State column has index 1, Country has index 2 and Region has index 3)

  3. Save the script and refresh the dashboard


widget.on('domready', function(se, ev){
	
	let columnIndex = 3
	
	$(`table tr > *:nth-child(${columnIndex})`, element).css('display', 'none')
	
	const elementToObserve = $('table tbody', element)[0];
	
	const observer = new MutationObserver(function(e) {

		for(const m of e) {
			if (m.type === 'childList') {
				$.each(m.addedNodes, function(index, value){
					$(value).find(`td:nth-child(${columnIndex})`).css('display', 'none')

				})
			}
		}
	})
										  
	observer.observe(elementToObserve, {subtree: true, childList: true});
	
})

520 views1 comment

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Heather Vibberts
Heather Vibberts
Dec 07, 2023

how do you take this script and hide multiple columns?


Like
BI Next Level white logo

BI Next Level is your trusted resource for BI customization, data solutions, and expert insights. Explore practical tips, scripts, and tutorials for tools like Sisense, Python, and SQL. Let’s transform your data into impactful insights together.

Quick Links
Connect with us
Copyright © 2024. All Rights Reserved. Designed, Developed & Maintained  by Intertoons
bottom of page