How to dynamically configure table columns

Hi!

I have some array tags with the historian configured.
This means that whenever I want to show the data in a table I need to configure each column of the data. However, we don't know how long is the array and what type is going to be.

The first column is always a timestamp, the other columns are the type of the array.

If I dont configure the props.columns the timestamps doesn't get shown correctly. If I configure the props.columns it will always show the amount of columns that are configured. If the array has any other amount it will not show some data or show empty columns.

How could I configure it so it will always show the timestamp correctly but also the correct amount of columns depending on the array lenght?

Also, would be nice not having a complex binding script (if any).

Thx!

You need to script it.

  • Create a property binding on the table's columns property and bind it to the table's data property. This will trigger the binding to reevaluate any time the data changes.
  • Add a Script Transform operation, cycle through the columns and add them to the data to be returned from the function. Advice here is to write the script in the Project Browser | Scripting | Project Library and call it from the Script Transform, passing the data into the function..

Your script will need a protype for the t_stamp column and for one of the other columns. Set those up in designer and copy each into your script as JSON variables, modifying the field name to that of the column name in each case.

2 Likes

Thx!

Is a bit sad that I need a script, would be nice to do it automatically. Or being able to configure only specific columns (as the timestamp).

Now I'm trying to resolve why the historian is not saving the array when is set OnChange :confused:
But that is another history...

Thanks transistor!

I figured it out!

Changing the value of an array doesn't update the timestamp. This mean that the historian doesn't save it. However, If u write the entire tag as an array. It does update the timestamp and saves it.