# Detecting selection changes in Vision table allowing multiselection

**URL:** <https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475>\
**Category:** Ignition\
**Created:** [October 7, 2020, 10:05pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475 "2020-10-07T22:05:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jross2020](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jross2020](https://forum.inductiveautomation.com/u/jross2020)\
**Post date:** [October 7, 2020, 10:05pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/1 "2020-10-07T22:05:31Z")

</div>

I want to detect when the currently selected row(s) change in a Vision table, configured to allow multiple row selection. Binding a script to the “propertychange” event, I see that a “selectedRow” event is generated _only_ when the lowest selected row index changes, which rules out the majority of changes the user may make in the selection. Since there’s no “selectedRows” property, I need to 1) somehow detect when the selection has changed and then 2) invoke getSelectedRow() on the table to see which rows are currently selected…  
My trouble is that there doesn’t seem to be a way to do 1) reliably (ie, for every change). Any advice?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 8, 2020, 8:12pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/2 "2020-10-08T20:12:18Z")

</div>

Consider using a Power Table instead, using the _ **selectedRows** _ property (Not to be confused with _ **selectedRow** _)

---

<div class="post-metadata">

**Author:** ![jross2020](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jross2020](https://forum.inductiveautomation.com/u/jross2020)\
**Post date:** [October 9, 2020, 12:01pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/3 "2020-10-09T12:01:48Z")

</div>

Does it have it? I don’t see it documented in [https://docs.inductiveautomation.com/display/DOC80/Vision+-+Power+Table](https://docs.inductiveautomation.com/display/DOC80/Vision+-+Power+Table), neither does it show in the component’s properties pane.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 9, 2020, 12:07pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/4 "2020-10-09T12:07:34Z")

</div>

Well, yeah, as I checked it out before posting. 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 9, 2020, 12:25pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/5 "2020-10-09T12:25:35Z")

</div>

This snippet is from the link you posted;  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbf3147af330691343a22fce9f12ba9c701aeae9.png)

---

<div class="post-metadata">

**Author:** ![jross2020](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jross2020](https://forum.inductiveautomation.com/u/jross2020)\
**Post date:** [October 9, 2020, 12:46pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/6 "2020-10-09T12:46:41Z")

</div>

That’s not a property.

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 9, 2020, 1:02pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/7 "2020-10-09T13:02:59Z")

</div>

Right. But you can use this to achieve what you described in your first post.  
You could also make use of the extension function onMouseClick which would fire everytime you click on a row. Try adding this in the onMouseClick and see if you can achieve what you want:

```auto
print self.getSelectedRows()
```

---

<div class="post-metadata">

**Author:** ![jross2020](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jross2020](https://forum.inductiveautomation.com/u/jross2020)\
**Post date:** [October 9, 2020, 1:14pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/8 "2020-10-09T13:14:36Z")

</div>

That works, although is not optimal (though of course still better than nothing), because any code you put there you would also have to put in the keyboard event handler, since selection can be changed with keyboard as well. That’s why I was looking for a central notification mechanism that would tell me “selection has changed”, regardless of how user did it.  
Thanks

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 9, 2020, 1:28pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/9 "2020-10-09T13:28:10Z")

</div>

A simple solution to that would be to create your own method and point all the event handlers or extension functions to it. Your code would reside in 1 place.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 9, 2020, 2:04pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/10 "2020-10-09T14:04:59Z")

</div>

In the propertyChanged event handler:

```python
if event.propertyName == 'selectedRows':
    do_some_stuff

```

This vid shows the properties fired.

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/098f0fd4a80ad75e9faa7da83737a8c4b2678057.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/098f0fd4a80ad75e9faa7da83737a8c4b2678057.mp4)

---

<div class="post-metadata">

**Author:** ![jross2020](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jross2020](https://forum.inductiveautomation.com/u/jross2020)\
**Post date:** [October 10, 2020, 5:43pm UTC](https://forum.inductiveautomation.com/t/detecting-selection-changes-in-vision-table-allowing-multiselection/39475/11 "2020-10-10T17:43:51Z")

</div>

Yes, that’s cool thanks. In this specific case the tables in question have lots of additional config and scripting attached, so replacng them with power tables would probably be a lot of work, so for this time I’ll go with the other solution. However for new tables I’d certainly use your method. Thanks
