Perspective fixed table header

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?

Show us your query.

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

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 =,‘application/json’,jsonParams)

decodedDict = system.util.jsonDecode(postReturn)
self.getSibling(“gridCodeIDTableList”) = 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 :

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

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

The field property must match a column name in, 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.

I set the column like :

And display like :

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:

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

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

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.

Set columns[0].field to have a value of “code_id”. Set columns[0].header.title to “Code Id”.

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

1 Like