onEditCellCommit event on CheckBox behavior

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)

Try putting the checkbox as a rendered view for that column in the table.

When I switch the column to a rendered view, the CheckBoxes disappear, making it appear as a column of blank values (see image below). If I then click in the column, that cell appears like a text box with the word "True" or "False", and the click does not update the underlying bound table anymore.

On that column, have you set viewPath and viewParams?

I figured out how to create a rendered view with a simple checkbox and added that to my table (setting the viewPath and viewParams). When clicking on the checkbox it shows "True" or "False" as in a text box, then if you step off, it appears again as a checkbox. That is two clicks, just as I started out with before this rendered view method. Still seeking for a single click solution. This is not it.

I'm not sure what is creating this issue. I have done this multiple times. Can you try removing the script that you have mentioned above onEditCellCommit and check if it's working as expected?

The script was not the issue. When I made the column not editable on the table, the rendered view became a single click.

4 Likes