# Button event select all rows in table

**URL:** <https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579>\
**Category:** Ignition\
**Created:** [November 9, 2011, 9:22pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579 "2011-11-09T21:22:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [November 9, 2011, 9:22pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/1 "2011-11-09T21:22:24Z")

</div>

is there a way to code a button to select all the rows in a table?

---

<div class="post-metadata">

**Author:** ![Greg.Buehler](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Greg.Buehler](https://forum.inductiveautomation.com/u/Greg.Buehler)\
**Post date:** [November 9, 2011, 9:38pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/2 "2011-11-09T21:38:46Z")

</div>

If I’m not mistaken:

```auto
table = event.source.getComponent("yourtable")
table.selectAll()
```

Since the Ignition components inherit from Swing components, you can use the functions in the Swing documentation 99% of the time.

[download.oracle.com/javase/6/doc … selectAll(](http://download.oracle.com/javase/6/docs/api/javax/swing/JTable.html#selectAll())

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [November 9, 2011, 9:46pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/3 "2011-11-09T21:46:39Z")

</div>

no that does not work.

`Traceback (innermost last):
  File "<event:actionPerformed>", line 2, in ?
AttributeError: selectAll
`

---

<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:** [November 10, 2011, 2:48pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/4 "2011-11-10T14:48:16Z")

</div>

Hi Jonathan,

Try this:

```auto
#this code is on the actionPerformed event of a button in the same container as the table
rowCount = event.source.parent.getComponent('Table').data.rowCount
event.source.parent.getComponent('Table').viewport.view.addRowSelectionInterval(0,rowCount-1)
```

Dan

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [November 10, 2011, 4:36pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/5 "2011-11-10T16:36:23Z")

</div>

Thanks, that works.

So how did you know about the property rowCount on a dataset? How did you know about viewport.view.addRowSelectionInterval()? I do not see any of those in the FactoryPMI or Ignition documentation.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 10, 2011, 4:59pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/6 "2011-11-10T16:59:13Z")

</div>

[quote=“Jonathan”]Thanks, that works.

So how did you know about the property rowCount on a dataset? How did you know about viewport.view.addRowSelectionInterval()? I do not see any of those in the FactoryPMI or Ignition documentation.[/quote]

rowCount on DataSet is [hiding in the user manual.](http://inductiveautomation.com/support/usermanuals/ignition/working_with_different_datatyp.htm?zoom_highlightsub=dataset)

The whole viewport.view.addRowSelectionInterval is him accessing the properties of Java Swing components.

See [JScrollPane](http://download.oracle.com/javase/6/docs/api/javax/swing/JScrollPane.html) and [JTable](http://download.oracle.com/javase/6/docs/api/javax/swing/JTable.html).

A bit more advanced stuff than usual going on here.

---

<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:** [November 10, 2011, 5:03pm UTC](https://forum.inductiveautomation.com/t/button-event-select-all-rows-in-table/3579/7 "2011-11-10T17:03:37Z")

</div>

While I have used the java references to figure out how to accomplish some tasks in jython, I most likely adapted this specific piece of code from a post in the forum:

[http://inductiveautomation.com/forum/viewtopic.php?p=9502#p9502](http://inductiveautomation.com/forum/viewtopic.php?p=9502#p9502)

Dan
