# Hide id column from 'Table' component

**URL:** <https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [November 17, 2023, 8:31am UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031 "2023-11-17T08:31:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rickard\_Nordwall](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rickard\_Nordwall](https://forum.inductiveautomation.com/u/Rickard_Nordwall)\
**Post date:** [November 17, 2023, 8:31am UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/1 "2023-11-17T08:31:29Z")

</div>

Hi,

Why can't I hide the 'id' column in a table component i perspective?  
I managed to hide other columns, but if I try to hide 'id' it will be shown as the last column.  
I have this code;

 ![columnIssue](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/924a33caabad7463f3631df487957ce35d305e9d.png)

hiding the column named 'copoPLC' works fine but not the 'id' one.  
Any idea what goes wrong here?  
The 'id' column is the primary key for the table but that shouldn't affect anything since I retrieve the SQL table as a dataset.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 17, 2023, 11:48am UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/2 "2023-11-17T11:48:39Z")

</div>

Many of the column options only work when the `columns.x.field` property matches the name of a column in `props.data`. If you haven't done that then I wouldn't expect the table component to know which column to hide.

---

<div class="post-metadata">

**Author:** ![Rickard\_Nordwall](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rickard\_Nordwall](https://forum.inductiveautomation.com/u/Rickard_Nordwall)\
**Post date:** [November 17, 2023, 1:25pm UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/3 "2023-11-17T13:25:21Z")

</div>

The dataset column name is the same as props.column[number].field

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 17, 2023, 1:39pm UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/4 "2023-11-17T13:39:07Z")

</div>

OK. How about the line,  
`if rows[1] == u'id' or rows[1] == u'copoPLC':`

Is `id` really column 1?

---

<div class="post-metadata">

**Author:** ![Rickard\_Nordwall](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rickard\_Nordwall](https://forum.inductiveautomation.com/u/Rickard_Nordwall)\
**Post date:** [November 17, 2023, 1:48pm UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/5 "2023-11-17T13:48:57Z")

</div>

'id' is the first column in the dataset.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 17, 2023, 1:54pm UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/6 "2023-11-17T13:54:06Z")

</div>

OK. I'm expecting that to return an integer but you seem to be checking for two string values in column 1, 'id' or 'copoPLC', and if either are found in column 1 of any row in the dataset you are going to hide the whole column. Why would the id column contain the value 'id'?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [November 20, 2023, 4:22pm UTC](https://forum.inductiveautomation.com/t/hide-id-column-from-table-component/82031/7 "2023-11-20T16:22:14Z")

</div>

That script is terribly inefficient, repeating the same logic for every row in the dataset when every row is guaranteed to have the same structure; assuming a dataset of, say, 100 rows, you'd looking at executing all of this logic 100 times while your dataset likely only has N number of columns. Even of those N columns, you only ever actually configure Table columns for `rows[0]` and `rows[1]`.

On top of that, `self.parent.parent.getChild("Table").getChild("Table")` should fail to identify a component as Tables are not containers and therefore should (almost) never have children.

This (pseudo) code should configure your columns as needed:

```auto
# your code here, up until just after you've acquired your dataset
headers = system.dataset.getColumnHeaders(dataset)
columns = []
ignored_columns = ["id", "copoPLC"]
for i, header in enumerate(headers):
    if header not in ignored_headers:
        should_be_visible = i < 22 # based on your provided max column count
        columns.append({"field": header, "editable": True, "dateFormat": "MM/DD/YYYY HH:mm:ss", "visible": should_be_visible})
self.parent.parent.getChild("Table").props.columns = columns

```
