# selectedRows for perspective Table?

**URL:** <https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [December 9, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424 "2022-12-09T12:01:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [December 9, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/1 "2022-12-09T12:01:22Z")

</div>

Can we retrieve the selected row indexes of a perspective table with selection mode **"multiple interval"**?

---

<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:** [December 9, 2022, 12:39pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/2 "2022-12-09T12:39:47Z")

</div>

It looks like `props.selection.selectedRow` just supplies the row number of the last-clicked item.

If there is a unique column in the table you could script a search for the values returned in `props.selection.data` and return the selected row numbers.

What is the real problem you are trying to solve?

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [December 9, 2022, 12:55pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/3 "2022-12-09T12:55:12Z")

</div>

Yes, vision table has a convenient .getSelectedRows().  
Nothing for perspective Table...

I need to remove multiple line in a table with data binded to a dataset.  
To update the dataset, selected row indexes would have been the more simple method...

---

<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:** [December 9, 2022, 2:17pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/4 "2022-12-09T14:17:28Z")

</div>

> [@mazeyrat](#):
>
> selected row indexes would have been the more simple method

It might not. There wouldn't be a correspondence between the table row numbers and the database row numbers.

You can retrieve the record IDs and not display them in the table. That way you can retrieve a list of record IDs from `props.selection.data` for your SQL delete.

---

<div class="post-metadata">

**Author:** ![jasoncoope](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jasoncoope/32/18674_2.png) [@jasoncoope](https://forum.inductiveautomation.com/u/jasoncoope)\
**Post date:** [July 29, 2023, 2:58pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/5 "2023-07-29T14:58:43Z")

</div>

I have the same ask. I have table selection mode set to multiple interval and these are the row/cols I want to update when a value is received, but the table selection properties give no indication of which rows have been selected.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/76a00aa3552e4d10d9cd74e02d807f49ddbf269b.png)

@mazeyrat Did you find a solution to this?

---

<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 29, 2023, 3:27pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/6 "2023-07-29T15:27:27Z")

</div>

As suggested previously,

- Add a row ID column to the table's datasource but don't display it.
- Loop through `selection.data` and update the relevant datasource rows by datasource ID.
- Refresh the binding (if required).

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 29, 2023, 4:32pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/7 "2023-07-29T16:32:59Z")

</div>

Yes that is the solution

---

<div class="post-metadata">

**Author:** ![jasoncoope](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jasoncoope/32/18674_2.png) [@jasoncoope](https://forum.inductiveautomation.com/u/jasoncoope)\
**Post date:** [July 30, 2023, 2:57pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/8 "2023-07-30T14:57:08Z")

</div>

I have an id column configured and not displayed, but the selection data only returns the value of the selected row/col when mode is set to multiple interval.

Possibly a bug? I noticed that when scripting to change the selected column, sometimes the selection data returns the whole rows data instead of just the selected columns value.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/b/6bf47aca83bc40cc3afa604cd6bdcd8921a88116.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 30, 2023, 3:07pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/9 "2023-07-30T15:07:01Z")

</div>

Try  
`selection.enableColumnSelection : false`  
That way you should get whole rows.

---

<div class="post-metadata">

**Author:** ![jasoncoope](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jasoncoope/32/18674_2.png) [@jasoncoope](https://forum.inductiveautomation.com/u/jasoncoope)\
**Post date:** [July 30, 2023, 3:11pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/10 "2023-07-30T15:11:01Z")

</div>

Except that I need the user to select individual columns. They select a column and then add a check value. They can select multiple columns and that value is applied to all selected cells. They select multiple row cells and the value is applied to those as well.

I'll put a ticket in with IA but I appreciate your help. thx.

---

<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 30, 2023, 4:32pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/11 "2023-07-30T16:32:06Z")

</div>

You could try keeping track of them yourself. I've just tried it and had mixed success.

- Create a custom property on the table. I called mine `selectedCells` and made it an array.
- Create a binding on the `custom.selectedCells`.

 ![Table multi-select](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/0/406a8baefdd7b79ab284e7c4d09f6c6ded76e09a.png)

> **Script**
>
> ```auto
> def transform(self, value, quality, timestamp):
> selectedCells = self.custom.selectedCells
> selectedCells.append([value.row, value.column])
> return selectedCells	
> 
> ```

Problems:

- I'm getting some double events resulting in duplicates in the table.
- You'll need a reset button to clear the selection.

I tried playing around with table events and the `onSelectionChanged` event looked promising but I discovered that (in Designer at least) that it fires before `props.selection.selectedRow` and `props.selection.selectedColumn` get updated.

---

<div class="post-metadata">

**Author:** ![jasoncoope](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jasoncoope/32/18674_2.png) [@jasoncoope](https://forum.inductiveautomation.com/u/jasoncoope)\
**Post date:** [July 30, 2023, 7:27pm UTC](https://forum.inductiveautomation.com/t/selectedrows-for-perspective-table/67424/12 "2023-07-30T19:27:00Z")

</div>

> [@jasoncoope](#):
>
> They select a column and then add a check value. They can select multiple columns and that value is applied to all selected cells. They select multiple row cells and the value is applied to those as well.

That's an idea. There's always a way, I'll put that in place, but have submitted a ticket, ideally it'll be part of the standard table functionality along with freeze columns/rows and draggable rows
