# Text tree to Tree component 'items' property

**URL:** <https://forum.inductiveautomation.com/t/text-tree-to-tree-component-items-property/75453>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 23, 2023, 1:30pm UTC](https://forum.inductiveautomation.com/t/text-tree-to-tree-component-items-property/75453 "2023-06-23T13:30:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [June 23, 2023, 2:44pm UTC](https://forum.inductiveautomation.com/t/text-tree-to-tree-component-items-property/75453/2 "2023-06-23T14:44:02Z")

</div>

I've been using a modified version of this:

> [@Dynamically build Tree items binding from tag path](https://forum.inductiveautomation.com/t/dynamically-build-tree-items-binding-from-tag-path/60869/6):
>
> Something like this, perhaps? path = "Treatment/3KNG/200/100\_01\_Basin1\_Mixer1" parent = [] ret = parent for part in path.split("/"): item = { "label": part, "expanded": True, "items": parent } parent.append(item) parent = [] return ret

I'm using this code in a script transform. Original binding is to a dataset containing path data. ex: "A/B/C"

```auto
items = []
for row in range(value.rowCount):
	path = value.getValueAt(row, 0)
	
	current = items
	for part in path.split("/"):

		# Check if the current folder exists in our items list
		folderExists = False
		for itemsPointerItem in current:
			if part == itemsPointerItem['label']:
				folderExists = True
				current = itemsPointerItem['items']

		if not folderExists:
			item = {
				"label": part,
				"expanded": False,
				"items": [],
				"data": path,
				"icon": {
				  	'path': 'material/stop',
				  	'color': 'red',
				  	'style': {}
				} 
			}
			current.append(item)
			current = item['items']

return items

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/text-tree-to-tree-component-items-property/75453)._
