# Perspective fixed table header

**URL:** <https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 24, 2021, 12:59pm UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560 "2021-01-24T12:59:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiawei.liu](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jiawei.liu](https://forum.inductiveautomation.com/u/jiawei.liu)\
**Post date:** [January 24, 2021, 12:59pm UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/1 "2021-01-24T12:59:20Z")

</div>

I wrote a script to query data in the database. This script is used by multiple tables, and the header fields to be displayed in each table are different. Whether it is possible to fix the header fields to be displayed in the table without being affected by the data fields returned by the script?

---

<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:** [January 24, 2021, 2:31pm UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/2 "2021-01-24T14:31:15Z")

</div>

Show us your query.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 24, 2021, 9:35pm UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/3 "2021-01-24T21:35:15Z")

</div>

Yes, the table.props.columns config determines which columns are shown and how. If default, then all columns are shown

[https://docs.inductiveautomation.com/display/DOC80/Perspective+-+Table](https://docs.inductiveautomation.com/display/DOC80/Perspective+-+Table)

---

<div class="post-metadata">

**Author:** ![jiawei.liu](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jiawei.liu](https://forum.inductiveautomation.com/u/jiawei.liu)\
**Post date:** [January 25, 2021, 9:27am UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/4 "2021-01-25T09:27:57Z")

</div>

The script I wrote is to call the Web Service, the query data is completed in the Web Service, and the script is to directly send the results of the Web Service to the table for use.

Script to return data like:  
**# encode dictionary to JSON**  
**jsonParams = system.util.jsonEncode(params)**

* * *

**# post to Ignition**  
**postReturn = system.net.httpPost(url,‘application/json’,jsonParams)**

* * *

**decodedDict = system.util.jsonDecode(postReturn)**  
**self.getSibling(“gridCodeIDTableList”).props.data = decodedDict.get(“contents”).get(“result\_list”)**

Web Service return :  
**result\_list=[{site\_uuid=b93b692e-fa23-4809-a83c-eed2f62d78f2, site\_id=SITEA01, description=TEST, colligate\_rule\_id=, alias\_code=A, create\_user=ADMIN, create\_time=2021-01-21 10:58:52, lm\_user=ADMIN, lm\_time=2021-01-21 10:58:52}]}**

I only want to display two fields in the returned data in the table, so I set the column like :

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

But all the fields are still displayed in the table~~

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [January 25, 2021, 10:23am UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/5 "2021-01-25T10:23:38Z")

</div>

> [@jiawei.liu](#):
>
> result\_list=[{site\_uuid=b93b692e-fa23-4809-a83c-eed2f62d78f2, site\_id=SITEA01, description=TEST, colligate\_rule\_id=, alias\_code=A, create\_user=ADMIN, create\_time=2021-01-21 10:58:52, lm\_user=ADMIN, lm\_time=2021-01-21 10:58:52}]}

There are not `code_id` or `code_category` fields in this value. You have to use field names that actually exist in your data.

---

<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:** [January 25, 2021, 3:57pm UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/6 "2021-01-25T15:57:11Z")

</div>

The `field` property must match a column name in `props.data`, or the column settings will be applied in order to the columns of the data. You should expand the `header` field, and apply the header value you want displayed for the table. This value will not change with the data, so to apply header fields to a table regardless of the data coming back, you should leave the `column.field` property empty, and you should assign a `column.header` value you want for that column.

---

<div class="post-metadata">

**Author:** ![jiawei.liu](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jiawei.liu](https://forum.inductiveautomation.com/u/jiawei.liu)\
**Post date:** [January 26, 2021, 5:40am UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/7 "2021-01-26T05:40:58Z")

</div>

I set the column like :

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

And display like :

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

When I execute Web Service, the output is:  
**result\_list=[{code\_id\_uuid=7fa0404f-21f4-4618-94fb-6cb03e1923cc, code\_id=KK\_CODE\_001, code\_type=CTYPE\_P\_01, code\_category=CCAT\_P\_01, is\_system\_reserved=NO, description=TEST, designated\_grade=, create\_user=null, create\_time=2021-01-21 05:02:52, lm\_user=null, lm\_time=2021-01-21 05:02:52, site\_id=null}, {code\_id\_uuid=5b43fda4-5f41-4f53-8e03-7126d3f50180, code\_id=TEST\_123, code\_type=CTYPE\_P\_01, code\_category=CCAT\_P\_03, is\_system\_reserved=NO, description=eww, designated\_grade=null, create\_user=null, create\_time=2021-01-24 03:40:39, lm\_user=null, lm\_time=2021-01-24 04:02:52, site\_id=null}]}**

And display is:

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

---

<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:** [January 26, 2021, 3:59pm UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/8 "2021-01-26T15:59:07Z")

</div>

You didn’t modify the `columns[x].header.title` property required to modify the header directly.  
 ![Screen Shot 2021-01-26 at 7.48.35AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/d/3dcf57e108b45f1d58d2700cc9927c04b5d86685.png)

Note that you must still identify which column of the data to be used. In my screenshot I was using the “default” data of the table, and so I specified “city” as the column to be used. The result of this configuration is that the data column identified by “city” will be used for the column, and the header will be “Code Id”.  
 ![Screen Shot 2021-01-26 at 7.52.16AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/5/f57733e06db4dfa0ec94b7d24cfc69853b902092.png)

The result of your second screenshot is due to two things:

1. It appears that you have two column entries `0` and `1` in the `columns` array. This configuration means that you only ever want to display two columns.
2. If you don’t specify a case-sensitive value match to one of your data columns, then the column configuration will use the first column it finds in the data. Since `columns[0].field` is “Code Id” and not “code\_id”, the column is not using the “code\_id” data column.

Instructions:  
Set `columns[0].field` to have a value of “code\_id”. Set `columns[0].header.title` to “Code Id”.

---

<div class="post-metadata">

**Author:** ![jiawei.liu](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@jiawei.liu](https://forum.inductiveautomation.com/u/jiawei.liu)\
**Post date:** [January 29, 2021, 7:27am UTC](https://forum.inductiveautomation.com/t/perspective-fixed-table-header/42560/9 "2021-01-29T07:27:12Z")

</div>

It’s successes!!  
Thank you for all your assistance. I really appreciate your help in resolving the problem.
