# onEditCellCommit event on CheckBox behavior

**URL:** <https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024>\
**Category:** Ignition\
**Tags:** scripting, database, python, perspective, ignition81\
**Created:** [July 27, 2023, 3:56pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024 "2023-07-27T15:56:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob.richards](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bob.richards](https://forum.inductiveautomation.com/u/bob.richards)\
**Post date:** [July 27, 2023, 3:56pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/1 "2023-07-27T15:56:01Z")

</div>

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)

```

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [July 27, 2023, 5:55pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/2 "2023-07-27T17:55:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bob.richards](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bob.richards](https://forum.inductiveautomation.com/u/bob.richards)\
**Post date:** [July 27, 2023, 8:31pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/3 "2023-07-27T20:31:03Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1bb03cfde67797a188fded6c267f80e9f7e849e0.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 27, 2023, 8:36pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/4 "2023-07-27T20:36:19Z")

</div>

On that column, have you set `viewPath` and `viewParams`?

---

<div class="post-metadata">

**Author:** ![bob.richards](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bob.richards](https://forum.inductiveautomation.com/u/bob.richards)\
**Post date:** [July 27, 2023, 10:47pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/5 "2023-07-27T22:47:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [July 28, 2023, 4:22am UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/6 "2023-07-28T04:22:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bob.richards](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bob.richards](https://forum.inductiveautomation.com/u/bob.richards)\
**Post date:** [August 10, 2023, 2:58pm UTC](https://forum.inductiveautomation.com/t/oneditcellcommit-event-on-checkbox-behavior/77024/7 "2023-08-10T14:58:42Z")

</div>

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