# Expand Specific Node on Tree View

**URL:** <https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041>\
**Category:** Ignition\
**Created:** [September 16, 2021, 5:25pm UTC](https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041 "2021-09-16T17:25:39Z")\
**Posts on this page:** 5\
**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:** [September 16, 2021, 5:25pm UTC](https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041/1 "2021-09-16T17:25:39Z")

</div>

Does anyone know why this code does not work to expand a specific path on a tree view? I do not get an error, but is also does nothing to the tree view on the window.

```auto
treeView = event.source.parent.getComponent('Tree View')

def expandNode(node, listPath):
	if(len(listPath) > 0):
		for childIndex in range(0, node.getChildCount()):
			child = node.getChildAt(childIndex)
			
			if(child.toString() == listPath[0]):
				print "expand node %s" % (child)
				treeView.expandNode(child, True)
				if(len(listPath) > 1):
					expandNode(child, listPath[1:])
						
				
expandNode(treeView.model.root, ["East Area", "Process", "Valve1"])

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [October 6, 2021, 7:33pm UTC](https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041/2 "2021-10-06T19:33:30Z")

</div>

Did you ever get this to work?

---

<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:** [October 6, 2021, 10:40pm UTC](https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041/3 "2021-10-06T22:40:04Z")

</div>

No, I did not.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [October 7, 2021, 12:16am UTC](https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041/4 "2021-10-07T00:16:52Z")

</div>

@paul-griffith Any ideas?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 7, 2021, 10:26pm UTC](https://forum.inductiveautomation.com/t/expand-specific-node-on-tree-view/51041/5 "2021-10-07T22:26:06Z")

</div>

Access to the underlying tree/model is unfortunately restricted in the tree view…

There’s a private method (`com.inductiveautomation.factorypmi.application.components.PMITreeView#_expandAll(TreePath parent, boolean expand)` - you can force access via reflection (made easier using [`MethodUtils`](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/reflect/MethodUtils.html#invokeMethod-java.lang.Object-boolean-java.lang.String-java.lang.Object:A-java.lang.Class:A-)) to try to invoke that manually.

Creating a TreePath might be somewhat awkward from Jython, because the two overloads accept `Object` or `Object[]`, which Jython will have a hard time distinguishing.

That may be enough to get started.
