Perspective: editable table

I'm using Ignition version 8.1.26. I'm a novice with Ignition so please bear with me--your feedback may be difficult for me to understand or implement.

I have a table component that correctly displays columns with their data from a database using a configure query binding. I want to allow a user to edit one of these columns, which has a data type int. I set the PROPS > Columns > "MyColumn" - editable:true. Then, I right-clicked on the table to access Event Configuration and selected onEditCellCommit* and added a script:

def runAction(self, event):
# Get the updated value and the row's unique identifier
new_value = event.value
row_data = self.props.data[event.row]['another_column_as_id']

    # Call the named query to update the database
    system.db.runNamedQuery("named_query", [new_value, row_data])
    
    # Optionally, refresh the table data
    self.refreshBinding("props.data")

I received this error:
Traceback (most recent call last):
File "function:runAction", line 4, in runAction
TypeError: 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset' object is unsubscriptable

Right click your table component, click on "Configure Events", add an "onEditCellCommit" event, and put a script action on it.

You can access the properties of the cell that you're editing via the "event" object.

You'll want to either write your update query here (using system.db) or write it in the project library and call it from here - it might look something like this:

EDIT:
You'll also want to make sure that you press enter to commit the value that you've entered in the cell. I don't think that clicking out of it will work.

Thank you Nick, I'll give this a try now.

Hi Nick, it's working for me now! Thank you very much for your help.

1 Like