Dynamic Column Attributes Data

Hi All,

I have a power table that is being populated thru a script, meaning the header and the data are build from the script. I have a boolean column, i want it to display a check box instead of 1 or 0.

I can’t set it up on the table customizer because the header will dynamically change. If the header change the boolean column will go back to displaying 1 or 0 instead of the checkbox.

So my question is, how can I passed in the column attributes using a script. Is that possible?

I would recommend playing around with the Power Table property called “Column Attributes Data”. If you look at a power table, that isn’t empty, you should see that the columns in the attributes dataset match all of the properties that you can manipulate from the Table Customizer. You can manually build this dataset property to whatever you need it to be so long as you follow the same column names and types.

Quick recommendation: I usually create a static (aka - has no binding) custom property of type dataset then copy and paste a Column Attributes Data property dataset, that has only 1 row, into this custom property. I can then grab this dataset inside my script so I don’t have to build the dataset from scratch and you can then add/modify as you see fit.

Good Luck!
-Will

Can I see an example of how you build the dataset property?

cause normally this is how you build the table right.

header = [col1, col2, col3]
data = [123,21123,3123]
system.dataset.toDataSet(headers, data)

Should be:headers = ["Col1", "Col2, "Col3"] data = [[col1val1, col2val1, col3val1], [col1val2, col2val2, col3val2], [etc, etc, etc]] new_dataset = system.dataset.toDataSet(headers, data)Note the square brackets in the data variable (list of rows).

Helpful links:
https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/52/0/how-to-work-with-datasets-in-ignition
https://inductiveautomation.com/news/how-get-data-out-dataset
https://docs.inductiveautomation.com/display/DOC/Working+with+Datasets
https://docs.inductiveautomation.com/display/DOC/system.dataset.toDataSet

Okay,

say I have the dataset for the table. But how do i Assign a column attribute property dynamically to a column?

say I want column1 to have Boolean?

The column datatype will match whatever datatype you use in each column of your rows to build the data variable (ie - data = [[True, 0.0, “Test”]] would result in a 3 column dataset with column 1 being type boolean, column 2 type float (I think, maybe double), and column 3 type string).

I’d recommend playing around with it some more on your own, digging into those help articles, and doing your own google searches for other sources.

I got it to work.

[code]headers =[“name”,“dateFormat”,“editable”,“filterable”,“hidden”,“horizontalAlignment”,“label”,“numberFormat”,“prefix”,“sortable”,“suffix”,“treatAsBoolean”,“verticalAlignment”,“wrapText”]

data.append([row,“MMM d, yyyy h:mm a”,“false”,“false”,“false”,"-9","","#,##0.##","",“true”,"",“false”,“0”,“false”])[/code]

thanks for the help

2 Likes