# How do you populate a treeview in perspective, I could not find any documentation on how to do it

**URL:** <https://forum.inductiveautomation.com/t/how-do-you-populate-a-treeview-in-perspective-i-could-not-find-any-documentation-on-how-to-do-it/85947>\
**Category:** Ignition Exchange\
**Tags:** perspective\
**Created:** [February 19, 2024, 3:59pm UTC](https://forum.inductiveautomation.com/t/how-do-you-populate-a-treeview-in-perspective-i-could-not-find-any-documentation-on-how-to-do-it/85947 "2024-02-19T15:59:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [February 19, 2024, 3:59pm UTC](https://forum.inductiveautomation.com/t/how-do-you-populate-a-treeview-in-perspective-i-could-not-find-any-documentation-on-how-to-do-it/85947/1 "2024-02-19T15:59:58Z")

</div>

Hello, I am trying to populate a treeview in perspective and I've been trying for the last 3 days and I can't seem to find a solution and I have yet to see any examples on how to implement it.

Here's what I did:

- **I used a query binding that is tied to items.**  

- I used a button to run the query and then throw the results in the tree.items property.

```auto
	data =system.db.runNamedQuery('Test_Path')
	lis =[]
	
	for item in data.getColumnAsList(0):
		lis.append(item)
		

	self.getSibling("Tree").props.items = lis
	

```

I was on the documentation page for the [Component](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/vision-components/tables/tree-view) and there is a .separationCharacter function that I don't know how to use I've tried adding this as property and I just cant get it to work.

My folder paths ar formated as such: \parentPath\child1\child2  
I've also replaced the '' with '/' because I saw somewhere that the default seperation path is '/'.

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [February 19, 2024, 4:20pm UTC](https://forum.inductiveautomation.com/t/how-do-you-populate-a-treeview-in-perspective-i-could-not-find-any-documentation-on-how-to-do-it/85947/2 "2024-02-19T16:20:42Z")

</div>

You need an array of objects (python dictionaries) in the format described here in the manual:

> **[Perspective - Tree | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-tree#properties)**
>
> The Tree component displays a tree hierarchy based on an array of objects.

If you want the tree to be nested, you will have to set that up yourself. The component won't automatically figure out how to parse through the paths that you pass to it.

The _items_ prop of the tree is a list of objects. Each of those objects has the props: _label, expanded, data, items_. That _items_ prop is another list of objects in the exact same format. And so on.

You'll have to write some python code to go through your paths and create the structure that the tree component expects.

---

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [February 19, 2024, 4:23pm UTC](https://forum.inductiveautomation.com/t/how-do-you-populate-a-treeview-in-perspective-i-could-not-find-any-documentation-on-how-to-do-it/85947/3 "2024-02-19T16:23:26Z")

</div>

Thank you, I will continue to work on it.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 19, 2024, 5:46pm UTC](https://forum.inductiveautomation.com/t/how-do-you-populate-a-treeview-in-perspective-i-could-not-find-any-documentation-on-how-to-do-it/85947/4 "2024-02-19T17:46:08Z")

</div>

You may find my post below helpful. The Tree component (not Treeview as you have in your title) is tricky because the 'items' property is recursive.

> [@Vertical menu tree in perspective](https://forum.inductiveautomation.com/t/vertical-menu-tree-in-perspective/75685/8):
>
> Here's how I did it. [Page configuration] Figure 1. Do the Page Configuration. Figure 2. Create the menu structure in text. I do this in the actual application. Note the use of the '|' pipe character to separate the menu and URL. Bind the tree's items property to the text and apply a script transform on it: 
> 
> > **The 'items' binding script transform.**
> >
> > def transform(self, value, quality, timestamp): # Update the test tree with the structure. # Anchors and path URL…

> **[Perspective - Tree | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-tree)**
>
> The Tree component displays a tree hierarchy based on an array of objects.
