How to get selected column name in Table Component?

Dear Inductive,

There are few hidden columns in our Table component and other visible columns. In addition to this our data to the table will keep on changing (Sometimes 3 Columns, sometimes 4 columns etc.). What we want is to get Selected Column Name (Not column index) on Cell or Column click ?

We tried to get the Column name using Column Attributes Data. However, it is producing improper results if any hidden columns present.

Please let us know how to resolve this at the earliest.

Thank you

You can get the column name via scripting:

table = event.source.getComponent("Table")
column_name = table.data.getColumnName(table.selectedColumn)

getColumnName will return the column name of an index in a dataset, and table.selectedColumn provides that index value for the getColumnName function.

Thank you James.

It is working well. I noticed all these things mentioned in the Manual under Working with Different Datatypes section. I apologize for not going through it properly.

No problem, glad you got it working.

Just posting as I had a similar need, but the solution above wasn’t working for me (using Ignition 8.0.9 so not sure if new script language versions could be issue). One of my coworkers had run into this previously and told me to use the script syntax below which worked. I believe they said there was another old thread on this forum from when they originally found this method, but we couldn’t find it.

“”"
table = event.source.parent.getComponent(‘TableName’)
table = table.getTable()
column = table.getColumnName(table.getSelectedColumn())
“”"