What is the syntax to edit a Power table's 'Table customizer' values from a script?

What is the syntax to edit a Power table’s ‘Table customizer’ values from a script?
Example(s): Header, Hide?, Editable, Sortable, etc are all possible values that can be edited.

My problem is when I go to copy the data from a powertable to another powertable none of those ‘Table Customizer’ values are copied so I need to format them using scripting.

tbl_db = event.source.parent.getComponent('tbl_database')
tbl_offline = event.source.parent.getComponent("tbl_offline")

tbl_offline.data = tbl_db.data

####
#ADD CODE HERE to update 'Table Customizer' values.
####

system.db.refresh(tbl_offline, "data")

Thank you for any assistance.

You need to copy (and/or modify) the ‘Column Attributes Dataset’ property - it’s in the advanced properties of the table, and has the values you’re looking for. I’m pretty sure that any change to the columns in the table’s dataset will automatically wipe the column attributes dataset, so depending on how you’re constructing your table you may need to react to the data property to repopulate the column attributes.

Attached is my updated code. Thanks for the help.

tbl_db = event.source.parent.getComponent('tbl_database')
tbl_offline = event.source.parent.getComponent("tbl_offline")

tbl_offline.data = tbl_db.data

####
 tbl_offline.columnAttributesData = tbl_db.columnAttributesData
####

system.db.refresh(tbl_offline, "data")

Yes, it did appear that without copying the columnAttributesData that just copying the data was erasing my ‘Table Customizer’ attributes data. Is there a way to edit specific attributes data without copying another tables attributes into it? For example if I just wanted to change the ‘name’ attribute what syntax would I use?

Thanks again!

No. It is only written by the table customizer in the designer. At runtime, any missing column attributes get defaults. And any extra column attributes in C-A-D that don’t match the table’s dataset are ignored. You can merge a bunch of C-A-D rows from various result sets to handle all of them at run time. No tool to help with that, of course.

1 Like
tbl_db = event.source.parent.getComponent('tbl_database')
tbl_offline = event.source.parent.getComponent("tbl_offline")
tbl_temp = event.source.parent.getComponent("tbl_temp")

tbl_offline.data = tbl_db.data
#tbl_offline.columnAttributesData = tbl_db.columnAttributesData

temp_dataset = system.dataset.setValue(tbl_offline.columnAttributesData, 0, 'name', 'blue')
tbl_offline.columnAttributesData = temp_dataset

system.db.refresh(tbl_offline, "data")
system.db.refresh(tbl_offline, "columnAttributesData")

So I was able to change the columnAttributes name in row 0 to ‘blue’ BUT i’m getting the following errors within the client console. (And the client screen doesn’t show ‘blue’ in the name column of my table.

system.db.refresh() was unable to find a refresh-compatible property binding on tbl_offline.data
system.db.refresh() was unable to find a refresh-compatible property binding on tbl_offline.columnAttributesData

Any thoughts?

You are writing new values to those properties in your script. Refresh is not needed or expected if a property doesn’t get its value from a binding.

1 Like

After some further testing on this subject I came up with the following:

tbl_db = event.source.parent.getComponent('tbl_database')
tbl_offline = event.source.parent.getComponent("tbl_offline")

tempAttributes = system.dataset.setValue(tbl_offline.columnAttributesData, 0, 'name', 'blue')
#tempAttributes = system.dataset.setValue(tbl_offline.columnAttributesData, 0, 'label', 'blue')
tbl_offline.columnAttributesData = tempAttributes

Which didn’t help me. The columns attribute data is updated but the ‘Table Customizer’ is not updated. The table on the screen is not updated either. In short, I can copy the entire columnAttributes data which does seem to update the ‘Table Customizer’ but I can’t update single attributes alone.