Get Table Column Attributes

I have a table attached to a database table that I want to allow the user to choose which columns he wants to look at. I have created a separate table that has the column names for the table and a new column (visible) to select if it should be hidden. I need to get the current hidden attribute value to update the selection table to populate the ‘visible’ column. I then need to set the attribute for hidden based on the change of the ‘visible’ column.

So, I’m looking at how to get and set table column attributes, and what attributes I can set.

You can use .columnAttributesData on your table to get the dataset…column hidden state is in there. It would be nice to put a cell binding on that first table’s column hide state attributes directly from the visible column of your second table, but I don’t think you can get at individual cell values that easily. You might have to do it through scripting on the second table by:

  1. Pull the first table’s columnAttributesData dataset
  2. Write a new dataset, inserting your updated hidden states (you’ll have to get these from the “Data” dataset on your second table)
  3. Push the new columnAttributesData dataset back to the first table

The only gotcha on this is that columnAttributesData does not automatically update on, say the column names change, or different number of columns come into the dataset.

Got something in the works. Gimme a bit longer. :thumb_right:

I created a hide table with most of the same column names. Anytime I change this table it toggles the update property on my table. And it refreshes the data table.

if event.propertyName == 'data':
	event.source.parent.getComponent('My Table').update = not event.source.parent.getComponent('My Table').update

Then on my table I added a custom property called “update” to call this code on property change.

# Create the Column Attributes Data table.
# First, let's set the defaults.
if event.propertyName == 'update':
    name = ''
    dateFormat = 'MMM d, yyyy h:mm a'
    editable = 1
    filterable = 0
    hidden = 0
    horizontalAlignment = '-9'
    label = ''
    numberFormat = '#,##0.##'
    prefix = ''
    sortable = 1
    suffix = ''
    treatAsBoolean = 0
    verticalAlignment = 0
    wrapText = 0
    # Now let's get rows loaded in the table.
    rows = []
    hidetable = event.source.parent.getComponent('Hide Table').data
    mytable =

    #See if I should hide this column.
    for name in mytable.columnNames:
                #See if column name exists
			hide = hidetable.getValueAt(0,name)
			newrow = [name, dateFormat, editable, filterable, hide, horizontalAlignment, label, numberFormat, prefix, sortable, suffix, treatAsBoolean, verticalAlignment, wrapText]
		#Ok, I can't find that column name. 
			newrow = [name, dateFormat, editable, filterable, hidden, horizontalAlignment, label, numberFormat, prefix, sortable, suffix, treatAsBoolean, verticalAlignment, wrapText]

	# Build the header
		headers = ["name", "dateFormat", "editable", "filterable", "hidden", "horizontalAlignment", "label", "numberFormat", "prefix", "sortable", "suffix", "treatAsBoolean", "verticalAlignment", "wrapText"]

    data = system.dataset.toDataSet(headers, rows)
    event.source.columnAttributesData = data

I used power tables and Ignition 7.7.2.
I am attaching the window I did to test for you.

Table Attribrutechange.proj (24.6 KB)

1 Like

Hi, JordanCClark,

I was wondering if you made any progress of this? I have a power table that will display the results of a query based on what the user selected. The headers and number of columns will change. I need to change the number format to always show 4 places after the decimal. I can change in the table customizer and through scripting, but since the column attributes data doesn’t change when the table is updated there is no way for me to make the change each time…any suggestions?

The table customizer updates the “ColumnAttributesData” dataset with the desired formatting. You can manually update that dataset through scripting like the example above. You can also simply add more rows describing what you want when certain column names show up in your dataset. You just have to remember to not use the customizer after that.

1 Like

Ah ok. Thanks. This helped a lot. I have it figured out now. I don’t know why it didn’t click before. shrugs