# Disabling the uncheck of checkbox on table through scripting

**URL:** <https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 19, 2021, 1:43pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944 "2021-07-19T13:43:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![archana.deshmukh](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@archana.deshmukh](https://forum.inductiveautomation.com/u/archana.deshmukh)\
**Post date:** [July 19, 2021, 1:43pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/1 "2021-07-19T13:43:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 19, 2021, 1:55pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/2 "2021-07-19T13:55:09Z")

</div>

The Table itself has no way to limit checkboxes in such a way that they only allow clicks to swap to an active state. For that kind of specialized logic you will need to render the column as a View and build your own view to use the only-on logic.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 19, 2021, 2:00pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/3 "2021-07-19T14:00:30Z")

</div>

Allow to select columns and rows and then you can use this in the “onSelectionChange”

This should get you started i guess  
(im using a json rn, a dataset will be a little different to get the value)  
Ofc you probably will have to add in to write to the db or tag where you got it from

```auto
	if event.selectedColumn == 'isActive':
		self.props.data[event.selectedRow]['isActive'] = not self.props.data[event.selectedRow]
['isActive']

```

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 19, 2021, 2:11pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/4 "2021-07-19T14:11:32Z")

</div>

~~I would expect that not to work at all because selectedColumn is returning the “name” of the column.~~

Edit: This reply was rushed. Please see a more thorough explanation below.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 19, 2021, 2:13pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/5 "2021-07-19T14:13:35Z")

</div>

The code above works for me  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/7/17d08c556abe791339071efc83fa949e08850395.png)  
one click on the column:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f06f77d8a17ee3d1ff7674f69627d9c80bd5cd3b.png)  
and again a click:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/7/17d08c556abe791339071efc83fa949e08850395.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/4110caea55fb43e5971aa76f80cc70ee5b1e1143.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 19, 2021, 2:52pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/6 "2021-07-19T14:52:15Z")

</div>

Sorry, that reply was rushed. What I meant to bring attention to was that the approach is not sufficient.

You are correctly applying logic based on the column name, but that logic is neither sufficient nor in the correct location.

1. The original poster only wants to allow for setting a checkbox to an active or `True` state; your code is changing the state regardless of the previous value and so is not any different than if no logic was applied at all. For example: if the checkbox is already `True`, your code will just change it to `False`.
2. Your code was supplied in the `onSelectionChange` Event, which will execute whenever a user clicks a cell which was not already selected. The code should be moved to the `onCellEditCommit` Event, which will require the code to be changed because the event has different keys available.

The `onEditCellCommit` Event seems to be able to manage the checkboxes as desired with the following code, where my column name happens to be “Boolean”.

```auto
	if event.colum == "Boolean":
		if self.props.data[event.row][event.column] == False:
			self.props.data[event.row][event.column] = True

```

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [July 19, 2021, 2:55pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/7 "2021-07-19T14:55:43Z")

</div>

```auto
if event.column == "Boolean": *****

```

😃

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 20, 2021, 9:09am UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/8 "2021-07-20T09:09:39Z")

</div>

Ah yes i just allowed to also return it to False, my bad.

But i do not like the onEditCellCommit for a simple boolean, because it requires more clicks instead of just one. (one or two to enter edit and one to check the box)  
I guess it just a personal prefference tho

---

<div class="post-metadata">

**Author:** ![archana.deshmukh](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@archana.deshmukh](https://forum.inductiveautomation.com/u/archana.deshmukh)\
**Post date:** [July 20, 2021, 2:14pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/9 "2021-07-20T14:14:56Z")

</div>

Thank you all for your help and suggestion but the code didn’t work for me.no worries i have added some work around for this issue. Thanks again.

---

<div class="post-metadata">

**Author:** ![archana.deshmukh](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@archana.deshmukh](https://forum.inductiveautomation.com/u/archana.deshmukh)\
**Post date:** [July 20, 2021, 2:16pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/10 "2021-07-20T14:16:26Z")

</div>

agree 😀 same issue i am also facing. it requires more clicks to select.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 20, 2021, 3:05pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/11 "2021-07-20T15:05:07Z")

</div>

> [@archana.deshmukh](#):
>
> same issue i am also facing. it requires more clicks to select.

This is why I recommend supplying your own view to handle editable data.

---

<div class="post-metadata">

**Author:** ![rajeshb](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@rajeshb](https://forum.inductiveautomation.com/u/rajeshb)\
**Post date:** [November 3, 2023, 1:40pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/12 "2023-11-03T13:40:52Z")

</div>

Any solution/fix identified in the latest perspective updates?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 3, 2023, 2:45pm UTC](https://forum.inductiveautomation.com/t/disabling-the-uncheck-of-checkbox-on-table-through-scripting/48944/13 "2023-11-03T14:45:10Z")

</div>

To do what ? What OP asked ?

Add this in a `onRowClick` event on your table:

```python
def runAction(self, event):
	if self.props.selection.selectedColumn == 'bool':
		self.props.data[event.row]['bool'] = True

```
