# How to get selected column name in Table Component?

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861>\
**Category:** Ignition\
**Created:** [July 23, 2012, 6:29pm UTC](https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861 "2012-07-23T18:29:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skallepalli](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@skallepalli](https://forum.inductiveautomation.com/u/skallepalli)\
**Post date:** [July 23, 2012, 6:29pm UTC](https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861/1 "2012-07-23T18:29:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [July 23, 2012, 7:48pm UTC](https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861/2 "2012-07-23T19:48:48Z")

</div>

You can get the column name via scripting:

```auto
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.

---

<div class="post-metadata">

**Author:** ![skallepalli](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@skallepalli](https://forum.inductiveautomation.com/u/skallepalli)\
**Post date:** [July 24, 2012, 6:18am UTC](https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861/3 "2012-07-24T06:18:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [July 24, 2012, 3:12pm UTC](https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861/4 "2012-07-24T15:12:21Z")

</div>

No problem, glad you got it working.

---

<div class="post-metadata">

**Author:** ![LandrethEdward](https://avatars.discourse-cdn.com/v4/letter/l/7bcc69/32.png) [@LandrethEdward](https://forum.inductiveautomation.com/u/LandrethEdward)\
**Post date:** [March 19, 2020, 6:03pm UTC](https://forum.inductiveautomation.com/t/how-to-get-selected-column-name-in-table-component/4861/5 "2020-03-19T18:03:40Z")

</div>

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())  
“”"
