# Having a Tree View component in vision mimic a folder directory?

**URL:** <https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [September 15, 2020, 2:46pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693 "2020-09-15T14:46:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 15, 2020, 2:46pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/1 "2020-09-15T14:46:50Z")

</div>

Doing some folder path reconciliation on a NAS drive via Ignition. I wanted to first scan all the folders to see where everything was at so I could display them in a tree view in a Vision window. Here’s a sample of how the data is stored -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/79441bc77a4ec17ef7690a5ed6bd31c360cf1b86.png)

I just used `os.walk` and saved each folder to the fullPath column of my table `pathreconciliation`.

Here’s my attempt at the SQL query for the Items of the tree

```auto
SELECT REPLACE(fullPath,SUBSTRING_INDEX(fullPath, '\\', -1),'') as 'path',REPLACE(fullPath,'\\','//') as 'fullPath', 
fullPath as 'text'
FROM pathreconciliation
WHERE depth <= 3
ORDER BY fullPath

```

and here is what I am seeing -  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e6f986690b00fc458cea40738b22161c7f7dfc2.png)

It is almost there but as you can see children are duplicated to be their own parent item as well and I am not sure how to fix this.

Any ideas how to fix this? I can edit the table if need be, I have full control over it if there’s way to manipulate this data into multiple columns if that helps somehow.

---

<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:** [September 15, 2020, 3:46pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/2 "2020-09-15T15:46:34Z")

</div>

Do you just need to update the ‘Separation Character’ property to a backslash? Or possibly replace the values in your query; the double backslashes at the root may make things weird.

---

<div class="post-metadata">

**Author:** ![Ethan.Strike](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethan.strike/32/13809_2.png) [@Ethan.Strike](https://forum.inductiveautomation.com/u/Ethan.Strike)\
**Post date:** [September 15, 2020, 4:02pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/3 "2020-09-15T16:02:29Z")

</div>

Adding on what PGriffith said, It may be possible the slashing of network mounted drives. It could be that ignition is using a slash as a special escape character. IE: To display “\\” as a string in ignition scripting, you may have to concatenate two additional “\\”'s like so:

`"\\" + "\\[Network Path here]"`

Here’s the documentation for [String Escape Characters](https://docs.inductiveautomation.com/display/DOC80/Strings#Strings-StringEscapeCharacter).

Another possible avenue (I am unsure if this is desired), but what if you adjusted your query different like…

- For child directories (or, sub directories) change the “isDir” value to “2” indicate it is not a directory but a child of the parent. Then add an additional where condition of to say where it is not a child directory

```auto
WHERE depth <= 3 and isDir not > 1

```

OR

- Added another column with a name of “isSub” with a value of 1 to indicate that it this data row is a Child. To indicate it is the parent the value of “isSub” would be 0. Again adding a where statement adjusted to account for that

```auto
WHERE depth <= 3 and isSub = 0 

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 15, 2020, 5:14pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/4 "2020-09-15T17:14:20Z")

</div>

Try setting the Separation Character of the treeview to ‘\’

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 15, 2020, 5:24pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/5 "2020-09-15T17:24:47Z")

</div>

Ugh I barely use this component so I forgot about this stuff. Thanks for the answer. That fixed it.

---

<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 13, 2024, 4:44pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/6 "2024-02-13T16:44:27Z")

</div>

How is he populating the treeview with the paths... I can write a query to retrieve the paths, but I can't script or bind a query so that the treeview becomes populated by the paths.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 13, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/7 "2024-02-13T16:50:03Z")

</div>

Tree Views require recursive items, so no dataset can possibly provide it. But you can **transform** a dataset that contains a flattened tree to construct the recursive tree the component needs.

---

<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 13, 2024, 4:52pm UTC](https://forum.inductiveautomation.com/t/having-a-tree-view-component-in-vision-mimic-a-folder-directory/38693/8 "2024-02-13T16:52:27Z")

</div>

Thank you, I'll do my best to transform the data retrieved.
