Making table columns invisible

Hi, I’m trying to programmatically make table columns visible or invisible. I’m using the following code, but it doesn’t seem to be working and the column remains visible:

$w(“#tblPerson”).columns[18].visible = false;

Hey there,

As documented here in the API Reference, you cannot change the columns in place. You need to get the columns data, change what you want, and then reset the columns property with the updated columns data.

What about just changing their width without having to reload everything?

Same story. You’re not reloading the data, but you need to reload the columns.

Thanks Sam, it worked! :slight_smile:

I’m trying to do the same here without success, can you show me an example of the code that works, I have tried to use a variable to set the visible as true or false but it only shows as visible.

Code Ex:

if (local.getItem("localSelNomeResp") === "true") { 
	tempCountCol = tempCountCol +1; 
	tempTableSize = tempTableSize + 200; 
	tempVisTurma = "true"; 
} 
else { 
	tempVisTurma = "false"; 
}	 
	$w("#tabReport").columns = [{ 
			"id": "col0", 
			"dataPath": "nomeResp", 
			"label": "Nome Responsável", 
			"type": "string", 
			"width": 250, 
			"visible": tempVisTurma 
			
	},{ 
			"id": "col1", 
			"dataPath": "nomeDep", 
			"label": "Nome do Aluno", 
			"type": "string", 
			"width": 250, 
			"visible": true 
	},{ 
			"id": "col2", 
			"dataPath": "dataNascDep", 
			"label": "Data Nascimento", 
			"type": "date", 
			"width": 100, 
			"visible": true 
	}]; 
	$w("#tabReport").refresh();

I believe I figured out the problem, the variable “tempVisTurma” should be empty to be considered a boolean FALSE, so now the code is working. Thanks.