# Is it possible to allow a user to select which table columns are shown?

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [September 23, 2024, 10:45pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325 "2024-09-23T22:45:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 23, 2024, 10:45pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/1 "2024-09-23T22:45:33Z")

</div>

This is a standard Vision table. I would like to allow users to select what columns they would like to see. By default I would like to have a handful, but if they need more information, they could select a few more.

Is this possible?

Side question: Is there multi-keyword search functionality in the forum search bar? As in, I want to search for threads that contain all the words: `one, two, three`. I tried using the `&` between words but not sure that worked.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 23, 2024, 11:01pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/2 "2024-09-23T23:01:02Z")

</div>

Yes, but you will need to do it by creating a new dataset for `Column Attributes Data` then set the columns you want shown to not hidden, and hide the rest. Since datasets are immutable you'll need to write your new dataset to the `Column Attributes Data` property.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 23, 2024, 11:55pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/3 "2024-09-23T23:55:22Z")

</div>

Is it possible to create a JSON dictionary or array object rather than a dataset? I don't see those options in the custom properties dialog.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 23, 2024, 11:57pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/4 "2024-09-23T23:57:41Z")

</div>

Try this example, I created a custom prop on the table as a dataset and a 2nd table where you can edit the column visibility and then send it to the original table.  
[TableExample.zip](https://forum.inductiveautomation.com/uploads/short-url/su27f1fZB8Fh8d251Ns7UWLCtjf.zip) (20.2 KB)

Edit:  
First export had way more rows that it needed.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 24, 2024, 12:09am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/5 "2024-09-24T00:09:15Z")

</div>

Can you post a screen shot or the code snippet? Downloads are restricted here.  
Thank you

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 24, 2024, 12:13am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/6 "2024-09-24T00:13:46Z")

</div>

This is the window:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2491c5027e3f3f9418e633fefc1c9707751eeb67.png)

Custom property on the table:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/b/3badd99663aa2812dac03d31da1ba5d91a841a95.png)

The right table has all other columns hidden and the hidden column set to editable.

And here is the set button:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/e/ae3636e46675d57a5876d22459481e88daaba6af.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 24, 2024, 1:19am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/7 "2024-09-24T01:19:15Z")

</div>

> [@mdemaris](#):
>
> Is it possible to create a JSON dictionary or array object rather than a dataset?

No, Document types are not supported by Vision Components.

(And it would be a performance killer--Dataset is an extremely efficient pure Java type.)

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 24, 2024, 8:47pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/8 "2024-09-24T20:47:16Z")

</div>

So the dataset for the custom property comes from a table in the database, or did you create a second Vision table (hidden)?

Sorry, I do not recognize the window you show and what it is attached to.

Then, would I need to have all the column headings in the (hidden) table for the `columnAttributesData` to work correctly? That doesn't seem right. So, you got the value and quality from where?

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 24, 2024, 9:05pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/9 "2024-09-24T21:05:08Z")

</div>

There is no database, the table on the left just has some random data for testing. The custom property is just a copy of the table's `columnAttributesData` dataset. The right table's data property is bound to the custom property and instead of showing all 30 columns, I hid all but the two shown.

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 25, 2024, 1:45am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/10 "2024-09-25T01:45:17Z")

</div>

Ok, I am almost there. I have two tables.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/01bcc4ea67e7c33ee31c9104ee4b9b7fae0905f8.png)

Left table is using test data, has a custom property called `ds`, but this table has no data in the `Column Attributes Data` property. I attempted to add the displayed column names in the `Column Attributes Data`, but got an error:

```python
IllegalArgumentException: No such property 'Col 1' on type 'ColumnAttributes'

```

So I used a named query, but still no attribute data. I just realized I am looking for the wrong information for the attributes... I need something like `name, data type`, etc. But, how do I get those attributes?

Ok, so I copied and pasted the attributes into the custom prop: `ds`, bound Right table's data to Left table `ds`.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/45bf24c5cfbe4b2be91791a1efa35ef99489a9c5.png)

Not sure how to hide all the extra columns in the Right table. Ok, I could not "hide" the extra columns but I could delete them in the `ds`, what a pain!

And how do I make it editable? Doesn't want to let me change the `hidden` box. No matter how many times I click, it won't work. Edit: I did use preview mode to try and change the `hidden` check box.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/da684bebc0670d4be100c3277377c0fb30d7d24b.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 25, 2024, 12:00pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/11 "2024-09-25T12:00:56Z")

</div>

The column attributes dataset on a table is only populated for you when you use the table customizer. Use it at least once.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 25, 2024, 1:00pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/12 "2024-09-25T13:00:31Z")

</div>

> [@mdemaris](#):
>
> But, how do I get those attributes?

If you double click on the table, or if you right click and select the Table Customizer from the Customizers item in the pop up menu, it will populate the Column Attributes Dataset.

That dataset will have a `hidden` column, which if selected will hide that column in the table.

> [@mdemaris](#):
>
> And how do I make it editable? Doesn't want to let me change the `hidden` box. No matter how many times I click, it won't work. Edit: I did use preview mode to try and change the `hidden` check box.

You have to set the column attributes of each column that you want to be editable to allow it. Then in the cellEdited event handler, you will need to modify the value of the dataset(s).

Something like this:

```python
#NOTE: this assumes that the right table's data property is bound to the
#left tables columnAttributesData property. The system.db.refresh on the last
#line forces the binding to update, which will insure that the two datasets match.

ds = event.source.parent.getComponent('Left Table').columnAttributesData
ds = system.dataset.setValue(ds,event.row,event.column,event.newValue)
event.source.parent.getComponent('Left Table').columnAttributesData = ds
system.db.refresh(event.source,'data')

```

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 25, 2024, 5:00pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/13 "2024-09-25T17:00:28Z")

</div>

But... there is no way to edit the Right table cells? I was hoping to find a way to allow users to select which columns are visible, kind of like a pen in the charts.

So I'm looking at the column attributes for the right table  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/54aae9c5cf7c5e6ddd390f48e0eb047fd7580b85.png)  
Trying to allow edits on the column titled `hidden`. Is this possible? Do I need to add something in the Header attribute?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 25, 2024, 5:02pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/14 "2024-09-25T17:02:03Z")

</div>

Select "editable" on the columns you want the user to be able to edit.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 25, 2024, 5:02pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/15 "2024-09-25T17:02:07Z")

</div>

You need a bidirectional binding from the table showing the columns to the main table's c-a-d property. Then you need to implement the edit handler extension script to update the column data (as a row).

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [September 25, 2024, 5:32pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-allow-a-user-to-select-which-table-columns-are-shown/96325/16 "2024-09-25T17:32:55Z")

</div>

OK, I understand now. Thank you, @josborn , @pturmel , @lrose !

I appreciate you all's patience.
