Ignition Power Tables (2024)

This is a guest post from Chris Powell.

Recently, Inductive Automation added a new table to their list of components. The name 'Power Table' is not understated. I want to share a few of the features I have found for some of the non-programming background developers out there.

Since the release of Ignition V7.7, Inductive Automation has added Extension Functions to several components. Extension functions are editable functions that exist on components that are used to customize components. Let us go over some of these features as they relate to the power table component.

First, put a power table table on a window. Then select TestData to load the table with data.

Ignition Power Tables (1)

You can paste the code from the following sections into each power table extension function to see how it works. I hope this will make your use of power tables faster and easier to implement in your next project.

configureCell Extension Function

I use this feature to highlight each individual cell on each row based on the row's value. With this code, I can change the background color based on that cell's value. You may add custom properties to the power table and access them with 'self.propertyName'. I created the custom property called 'highsp' and used it in line 2. Here is code for this:

 if colName == 'Float Column': if value > self.highsp: return {'background' : 'red'} elif value 

The only issue I noticed so far is the repaint of the table if you are using dynamic properties. So if my 'highsp' property changed, the table does not repaint. To fix this, add the following code to the propertyChange event handler:

if event.propertyName == 'highsp': event.source.parent.repaint()

This will force the table to repaint and you will see the changes.

While we are on the property changed event handler, this is where you will edit the Columns Attributes Data table. You create the entire table because it does not create itself unless you use the Table Customizer. The following code will build the Columns Attributes Data table from scratch each time new data is loaded. Add the following code to the property change event handler.

# Let's create the Column Attributes Data table.# First, let's set the defaults.if event.propertyName == 'data': 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 = [] table = event.newValue for k in table.columnNames: #Name of the column I want to be different from default. if k == 'Int Column': name = k # Makes the 'Int Column' hidden. newrow = [name, dateFormat, editable, filterable, 1, horizontalAlignment, label, numberFormat, prefix, sortable, suffix, treatAsBoolean, verticalAlignment, wrapText] else: name = k newrow = [name, dateFormat, editable, filterable, hidden, horizontalAlignment, label, numberFormat, prefix, sortable, suffix, treatAsBoolean, verticalAlignment, wrapText] rows.append(newrow) # 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

onCellEdited Extension Function

I mention this section because even if you have 'Editable' selected in the Column Attributes Data, it does not really edit anything. You need to enable this function and uncomment the code. I have added the code below. You also might want to add a call to 'system.db.runPrepUpdate' to send the update back to a database.

import systemself.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)
Ignition Power Tables (2024)
Top Articles
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 6036

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.