# Is there a way to select cells or rows in a Vision Power Table with scripting

**URL:** <https://forum.inductiveautomation.com/t/is-there-a-way-to-select-cells-or-rows-in-a-vision-power-table-with-scripting/90750>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 22, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-select-cells-or-rows-in-a-vision-power-table-with-scripting/90750 "2024-05-22T17:56:43Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![cbanzet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cbanzet/32/6207_2.png) [@cbanzet](https://forum.inductiveautomation.com/u/cbanzet)\
**Post date:** [May 30, 2024, 7:24pm UTC](https://forum.inductiveautomation.com/t/is-there-a-way-to-select-cells-or-rows-in-a-vision-power-table-with-scripting/90750/7 "2024-05-30T19:24:04Z")

</div>

So far I have not been able to get @justinedwards.jle suggestion to work and I'm trying to avoid the reflection that @pturmel mentions because I know nothing about reflection and I would like to avoid that advanced method if possible.

I have the mentioned settings on the table set correctly.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/afe32ea7a4660862b44a83cf1ef4b2bab5258fca.png)

but I should mention that ~~column selection is allowed~~ I have tried both column selection allowed and disallowed and that some of the columns are editable.

I tacked this code onto the end of what I had for troubleshooting purposes - _vrws_ is the list of originally selected valid rows.

```python
print "vrws: {}".format(vrws)
table = event.source.parent.getComponent('ptLengths').table
print "Selecting row: {}".format(vrws[0])
table.setRowSelectionInterval(vrws[0], vrws[0])
for i in range(1,len(vrws)):
	print "Selecting row: {}".format(vrws[i])
	table.addRowSelectionInterval(vrws[i],vrws[i])
nwrws = pt.getSelectedRows()
print "nwrws: {}".format(nwrws)

```

The code **acts** like it works, but in the end nothing in the table is selected and _nwrws_ is empty. This is the output to the console:

```python
vrws: [1, 2, 3, 4, 5, 6, 7]
Selecting row: 1
Selecting row: 2
Selecting row: 3
Selecting row: 4
Selecting row: 5
Selecting row: 6
Selecting row: 7
nwrws: array('i')

```

I also looked at the post [Programmatically Set Selected Cell in Power Table](https://forum.inductiveautomation.com/t/programmatically-set-selected-cell-in-power-table/21749) that @dkhayes117 mentions, and there may be some hope there with `table.changeSelection()` , but at the moment I'm trying to figure out how to make that work with a non-contiguous selection.

In the end, I had to use `table.changeSelection()`, and to make it work I had to use the _toggle_ and _extend_ flags differently than what seemed obvious to me. My confusion came from the fact that the _extend_ flag changes what it does based on the _toggle_ flag. When both flags are false, `table.changeSelection()`, **clears the previous selection** , and starts a new selection, but if _toggle_ is true and _extend_ is false, **the previous selection is not cleared** and the selection state of the cell referred to is simply toggled. That allowed the following code to work (I had to assume that nothing was selected after the aforementioned table changes).

```python
print "val_rws: {}".format(val_rws)
table = event.source.parent.getComponent('ptLengths').table
print "Selecting row: {}".format(val_rws[0])
table.changeSelection(val_rws[0], 0,0,0)
for i in range(1,len(val_rws)):
	print "Selecting row: {}".format(val_rws[i])
	table.changeSelection(val_rws[i],0,1,0)
nwrws = pt.getSelectedRows()
print "nwrws: {}".format(nwrws)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/is-there-a-way-to-select-cells-or-rows-in-a-vision-power-table-with-scripting/90750)._
