I have table that is bound to a database but i want to be able to edit any cell and have it update the database. Im using the onEditCellCommit action of the table and have this coded so far.
Def runAction(self, event):
Right now it just deletes the data. I was trying to copy the data entry example from the example quick start. Im very new to scripting so i couldnt really follow how they were doing it. Any suggestions would be appriciated!
You're not passing any parameters to your query, so it just sends nulls instead.
You need to pass a dict containing keys that match your query parameters:
What do i have to pass to the query to allow the values to stay. I need to define the value_for_trailer but how do i define it for whatever value is entered in the cell?
Your original query should be returning the id column (or whatever the unique key is for each row) and pass that back to the UPDATE query so that it knows which row to update. It would then look something like this:
UPDATE EvisData1
SET
Trailer = :Trailer,
Batch = :Batch
WHERE
id = :id
The id column can be displayed in the table (handy for debug) or not.
# Get the table component
table = self.parent.parent.getChild("Table")
# Get the selected row index
row = table.props.selection.selectedRow
# Check if a row is selected
if row is not None:
# Get the data from the selected row
rowData = table.props.data[row]
# Populate input fields with selected row data
self.parent.parent.getChild("ColumnContainer").getChild("BatchInput").props.value = rowData
I Couldnt get it with the editcellcommand so im trying with an edit button but its saying rowdata = table.props.data[row] is unscriptable. What am i doing wrong?