Power Table Editing

Hey everybody, i am new to using Ignition Designer and I need some help please. I have a power table with 3 columns and 52 rows. The last column i have put to editable meaning i can edit it during the preview or running mode.

The problem is, when i go on preview mode and edit a row in the 3 column, what i have put in does not seem to be seen on the table or saved on the row or cell im doing my editing. Can i please have some help with the scripting for power table to be able to save or make the value i put in stay or save in that cell, in pewview and editing mode please and thank you.

You have to use the onCellEdited method on the power table to write a script to send the new data to whatever data source you are using for the table.

If you are sourcing your table data from a DB, then your script would perform a DB insert or update.

1 Like

Thank you for responding. I do not have a data or DB, but rather I want to edit this row in the column and it will saved to a tag (memory dataset tag), but I just want to understand or know how to be able to make the table be edited during preview mode and the value i put in during this mode, it will show or be saved during and after preview mode. Please and thank you

@ryan.white's answer is correct. For your use case, simply use the onCellEdited extension function to create an updated dataset from the data property of the power table. Then, write the new value to the tag.

I assume you have the power table's data propery bound to the tag value?

table = event.source.parent.getComponent('powertable')

    rowIndex = event.rowIndex  
    colIndex = event.columnIndex  

    if colIndex == 2:
        newValue = event.newValue
        dataset = system.tag.read("[default]Dataset").value
        
    dataList = dataset.getDataAsList()

    for i in range(len(dataList)):
        if i == rowIndex:
            dataList[i][colIndex] = newValue

        updatedDataset = system.dataset.toDataset(dataset.getColumnNames(), dataList)
        system.tag.write("[default]Dataset", updatedDataset)

        print("Row {rowIndex}, Operator column updated with value: {newValue}")

And yes, the power table data property is bound to the tag value (Dataset)

But this code does not seem to work or do what i want. What have a done wrong here. (Thank you for you response and help by the way.)

That script looks way more complex than it should be. I would imagine it should look more like this:

#def onCellEdited(self, rowIndex, colIndex, colName, oldValue, newValue):
	newData = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)
	system.tag.writeBlocking(['path/to/tag'], [newData])
4 Likes

A digression, but I think if you make the binding to the tag bidirectional the script could literally just be:

self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)
4 Likes

You gotta love Ignition. Just when it seems it can't get any simpler, it does! :rofl:

3 Likes

Thank you very much for your helps, appreciate it and wish you guys an entertaining 2025

1 Like