Ignition vision hide a colomn from script

Hi, I am using a power table in ignition, and I like the fact that I can let my user to choose to hide or show a colomn, my problem is when I want to:

  1. give my user the choice of showing or hiding a column named id_list, and also
  2. hide that column by default

I think I will need to put it in a event handler, like if the page is openned, then I will hide the selected column by default, user can still right click the colomn headers and choose to show that specific colomn. Can someone tell me where to put this script and what will be the script? Thanks.

After doing some search and reading, I think the best place to put the scipt will be the initialize extension function, but I am still searching on how to refer to this column and put it’s hide property to True.

I usually build popup menus for that.
Put something like this on the onPopupTrigger extension function.

def hideColumn0(evt, cellValue=value):
	table = self
	columnData = table.columnAttributesData
	newData = system.dataset.setValue(columnData, 0, 'hidden', 1)
	table.columnAttributesData = newData
def showColumn0(evt, cellValue=value):
	table = self
	columnData = table.columnAttributesData
	newData = system.dataset.setValue(columnData, 0, 'hidden', 0)
	table.columnAttributesData = newData
menu = system.gui.createPopupMenu({'Hide ID Column':hideColumn0,'Show ID Column':showColumn0})
menu.show(event)
1 Like

Thanks you for your reply Maynard.

I put this code in the initialize, and it did hide the first column on openning, but I don't have the choice of unchecking the hide check in my right click menu. I want to uncheck id_liste in the image on openning the page.

table = self
columnData = table.columnAttributesData
newData = system.dataset.setValue(columnData, 0, 'hidden', 1)
table.columnAttributesData = newData

image

Anything hidden by script has to be unhidden by script.
Put the second part in the onPopupTriggered and it will have it in a popup script.