Running Ignition 8.1.22.
I have a perspective page with a bound table, and the table has a CheckBox column named IsEnabled.
I have a script in the OnEditCellCommit event (see script below) to update the underlying data, that is, to disable and enable, by updating the table to false or true depending if the Checkbox is unchecked or checked.
In the code below, the table is successfully updated, and further, the results are verified in a TextBox, to which I write at the end of the script.
The problem, I have to click the CheckBox twice, in order for the CheckBox to change from checked to unchecked, or vice versa. How can I check and uncheck in a single click? NOTE: If I put this same code in a OnRowClick event, I have the same issue.
Here is my script:
def runAction(self, event):
db="MyDB"
self.getSibling("TextField").props.text=""
if self.props.selection.selectedColumn == "IsEnabled":
isEnabled = not self.props.data.getValueAt(event.row, 'IsEnabled')
if isEnabled == True:
setEnabled = 1
else:
setEnabled = 0
id=self.props.data.getValueAt(event.row, 'MyID')
query = "UPDATE dbo.MyTable SET IsEnabled = ? WHERE MyID = ?"
args = (setEnabled, id)
system.db.runPrepUpdate(query, args, db)
self.refreshBinding("props.data")
self.getSibling("TextField").props.text="The id is: " + str(id) + " and the IsEnabled value has been changed to " + str(isEnabled)