# Set multiple row selection on powertable

**URL:** <https://forum.inductiveautomation.com/t/set-multiple-row-selection-on-powertable/14375>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [May 23, 2017, 7:33am UTC](https://forum.inductiveautomation.com/t/set-multiple-row-selection-on-powertable/14375 "2017-05-23T07:33:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [May 23, 2017, 7:33am UTC](https://forum.inductiveautomation.com/t/set-multiple-row-selection-on-powertable/14375/1 "2017-05-23T07:33:57Z")

</div>

A power table I made has the ability to change the order (a user can click an up and down button to move rows up and down). Getting the selection and updating the order works like it should.

The problem is that the selection isn’t updated. F.e. when a user selects rows [4, 5, 6], and presses the up-button, the selection should become [3, 4, 5].

But I can only find a way to set the selection to a single row. So the selection either stays [4, 5, 6], or I can set the selection to [3].

This is rather annoying for users, as they might want to move that set of rows another place higher, but they can’t just click the same button again as the selection is wrong.

I found that a table has a .selectedRow attribute that can be set (but only sets a single row to be selected), and a .selectedRows attribute, but the latter is read-only, so doesn’t help.

Is there any way to set such a selection?

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [May 23, 2017, 9:01am UTC](https://forum.inductiveautomation.com/t/set-multiple-row-selection-on-powertable/14375/2 "2017-05-23T09:01:28Z")

</div>

This is a feature missing from the power table. You can implement it yourself by getting a reference to the underlying JideTable:

```auto
table = event.source.parent.getComponent('Power Table')
jideTable = table.getTable()

```

You then have to access its ListSelectionModel ([https://docs.oracle.com/javase/8/docs/api/javax/swing/ListSelectionModel.html](https://docs.oracle.com/javase/8/docs/api/javax/swing/ListSelectionModel.html)):

```auto
listSelectionModel = jideTable.getSelectionModel()

```

The list selection model has a couple of methods to allow you to set and add multiple rows. For example, to select rows 1, 2, 3, 5 and 6, you could use:

```auto
listSelectionModel.setSelectionInterval(1, 3)
listSelectionModel.addSelectionInterval(5, 6)

```

Hopefully this helps.

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [May 23, 2017, 9:33am UTC](https://forum.inductiveautomation.com/t/set-multiple-row-selection-on-powertable/14375/3 "2017-05-23T09:33:21Z")

</div>

Thanks a lot, I didn’t realise I needed to use getTable() to find the original Java table.
