# Table Click Selected Row to Deselect

**URL:** <https://forum.inductiveautomation.com/t/table-click-selected-row-to-deselect/95920>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [September 12, 2024, 8:43pm UTC](https://forum.inductiveautomation.com/t/table-click-selected-row-to-deselect/95920 "2024-09-12T20:43:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [September 12, 2024, 8:43pm UTC](https://forum.inductiveautomation.com/t/table-click-selected-row-to-deselect/95920/1 "2024-09-12T20:43:22Z")

</div>

I want to be able to click the row that is already selected to go back to no selection (-1). How would I go about scripting that. The `onClick` fires after the value changes, so that didn't work for me.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [September 12, 2024, 10:40pm UTC](https://forum.inductiveautomation.com/t/table-click-selected-row-to-deselect/95920/2 "2024-09-12T22:40:32Z")

</div>

Just tried this out, and this seems to work. You'll need a custom property named `prevRow` on your table, then for the `mouseClicked` event, use this:

```python
newRow = event.source.selectedRow
if newRow == event.source.prevRow and newRow >= 0:
	event.source.selectedRow = -1
	newRow = -1
	
event.source.prevRow = newRow

```

One catch though is that if you are testing too fast, I think it sometimes catches your second click as a double-click and doesn't de-select.

Edit: Oh, and I set the default value of the custom property to -1 to start with just to be sure it's initialized properly.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [September 13, 2024, 1:08pm UTC](https://forum.inductiveautomation.com/t/table-click-selected-row-to-deselect/95920/3 "2024-09-13T13:08:30Z")

</div>

This works, but I'm not getting the same double-click behavior issue as you. The deselection always works for me.
