# Multi select in tree on reload

**URL:** <https://forum.inductiveautomation.com/t/multi-select-in-tree-on-reload/10637>\
**Category:** Ignition\
**Created:** [October 20, 2015, 11:15am UTC](https://forum.inductiveautomation.com/t/multi-select-in-tree-on-reload/10637 "2015-10-20T11:15:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![PerryAJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/perryaj/32/3281_2.png) [@PerryAJ](https://forum.inductiveautomation.com/u/PerryAJ)\
**Post date:** [October 20, 2015, 3:15pm UTC](https://forum.inductiveautomation.com/t/multi-select-in-tree-on-reload/10637/2 "2015-10-20T15:15:33Z")

</div>

You’ll want to use the ‘setSelectionRows()’ method of the underlying tree component. Here is a little code snippet that I set on a button to select a couple items on a default Vision Tree View component.

```auto
from javax.swing.tree import TreeSelectionModel

# get the underlying tree component
tree_component = event.source.parent.getComponent('Tree View').getComponent(0).getComponent(0)

#set our selection model to allow discontiguous selection (e.g., select rows 1 and 3 but not 2)
tree_component.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)

# the rows we want to select
selected_rows = [2,4]

# now apply the selection to the component
tree_component.setSelectionRows(selected_rows)
```

You’ll just need to work your selection logic into populating a list like ‘selection\_rows’. Hope this helps!

---

_[View the full topic](https://forum.inductiveautomation.com/t/multi-select-in-tree-on-reload/10637)._
