# Selecting Non-adjacent Rows

**URL:** <https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913>\
**Category:** Ignition\
**Created:** [July 23, 2013, 4:34pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913 "2013-07-23T16:34:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomranger](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@randomranger](https://forum.inductiveautomation.com/u/randomranger)\
**Post date:** [July 23, 2013, 4:34pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/1 "2013-07-23T16:34:53Z")

</div>

Hello again guys (skip first paragraph for short entry,)  
As I get deeper into working with this program, I find more things that don’t seem to have the straightforward API support that other stuff does, so I am lead here to see if anyone else knows how to do what I’m trying to do, and I feel a little guilty each time. To the point though, what I’m trying to do, is use the MouseClicked script within the Table component to select multiple rows in the table. So I took a look at the setRowSelectionInterval method. It’s close to what I want, but the rows I want to select are not always right next to each other, and I can’t reorder the table to get them next to each other either (due to the nature of the table).

How do I select multiple rows in a table component that are:  
1) Not next to each other  
2) Without reordering the table  
I do not believe that the setRowSelectionInterval method can help me.

---

<div class="post-metadata">

**Author:** ![dep05d](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dep05d](https://forum.inductiveautomation.com/u/dep05d)\
**Post date:** [July 23, 2013, 5:30pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/2 "2013-07-23T17:30:04Z")

</div>

Hi,

You can use addRowSelectionInterval

```auto
table = event.source.parent.getComponent('Table')
table.getTable().addRowSelectionInterval(1,2)
table.getTable().addRowSelectionInterval(6,8)
#etc
```

[http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JTable.html#addRowSelectionInterval(int,%20int)](http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JTable.html#addRowSelectionInterval(int,%20int))

Hope this helps,

Dan

---

<div class="post-metadata">

**Author:** ![randomranger](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@randomranger](https://forum.inductiveautomation.com/u/randomranger)\
**Post date:** [July 23, 2013, 5:45pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/3 "2013-07-23T17:45:50Z")

</div>

[quote=“dep05d”]Hi,

You can use addRowSelectionInterval

```auto
table = event.source.parent.getComponent('Table')
table.getTable().addRowSelectionInterval(1,2)
table.getTable().addRowSelectionInterval(6,8)
#etc
```

[http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JTable.html#addRowSelectionInterval(int,%20int)](http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JTable.html#addRowSelectionInterval(int,%20int))

Hope this helps,

Dan[/quote]

I don’t see an “addRowSelectionInterval” or “getTable” method in the Table components list of available methods.

---

<div class="post-metadata">

**Author:** ![dep05d](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dep05d](https://forum.inductiveautomation.com/u/dep05d)\
**Post date:** [July 23, 2013, 5:51pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/4 "2013-07-23T17:51:38Z")

</div>

Yeah, I guess it isn’t documented. I just picked up somewhere that getTable will return the actual JTable object. From there you have access to basically everything inside a standard java JTable. It would probably be helpful if the user manual highlighted how to get to underlying objects, along with a link to the java documentation.

Dan

---

<div class="post-metadata">

**Author:** ![randomranger](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@randomranger](https://forum.inductiveautomation.com/u/randomranger)\
**Post date:** [July 23, 2013, 5:56pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/5 "2013-07-23T17:56:11Z")

</div>

[quote=“dep05d”]Yeah, I guess it isn’t documented. I just picked up somewhere that getTable will return the actual JTable object. From there you have access to basically everything inside a standard java JTable. It would probably be helpful if the user manual highlighted how to get to underlying objects, along with a link to the java documentation.

Dan[/quote]

Oh, ok Thanks Dan. I’ve ran into that problem before, where there is something in the API but isn’t documented. Do you know if there is another place where I can get more documentation for Designer, cause I don’t like going to the forum each time when something I need isn’t in the API.

---

<div class="post-metadata">

**Author:** ![dep05d](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dep05d](https://forum.inductiveautomation.com/u/dep05d)\
**Post date:** [July 23, 2013, 6:07pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/6 "2013-07-23T18:07:40Z")

</div>

Not really, sorry. If I’m stuck on something, I’ll generally search the manual, then search through the forum, then try and see what java I can get into under the hood, then ask here or call support if I’m still stuck.

I wouldn’t feel guilty about posting here. It helps build a knowledge base for the community and highlight documentation gaps / needed features. And inevitably, you’ll find plenty of opportunities to answer questions to problems you’ve already encountered.

Good Luck!

Dan

---

<div class="post-metadata">

**Author:** ![markdobtech](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@markdobtech](https://forum.inductiveautomation.com/u/markdobtech)\
**Post date:** [July 23, 2013, 6:12pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/7 "2013-07-23T18:12:10Z")

</div>

Set the table property ‘Selection Mode’ to ‘Multiple Interval’. Mouse and will select/deselect interval rows (mouse and will select/deselect contiguous rows).

Use getSelectedRows() to return a list ints of selected rows.

---

<div class="post-metadata">

**Author:** ![randomranger](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@randomranger](https://forum.inductiveautomation.com/u/randomranger)\
**Post date:** [July 23, 2013, 6:12pm UTC](https://forum.inductiveautomation.com/t/selecting-non-adjacent-rows/6913/8 "2013-07-23T18:12:44Z")

</div>

[quote=“dep05d”]Not really, sorry. If I’m stuck on something, I’ll generally search the manual, then search through the forum, then try and see what java I can get into under the hood, then ask here or call support if I’m still stuck.

I wouldn’t feel guilty about posting here. It helps build a knowledge base for the community and highlight documentation gaps / needed features. And inevitably, you’ll find plenty of opportunities to answer questions to problems you’ve already encountered.

Good Luck!

Dan[/quote]

Ok thanks Dan, fortunately, I am actually a bit familiar with Java, as it was my first language, but I had no idea how much Ignition Designer depended on it, I’ll check java docs as a resource from now on. Thanks.
