# Search Option On Tag Tree

**URL:** <https://forum.inductiveautomation.com/t/search-option-on-tag-tree/57462>\
**Category:** Ignition\
**Created:** [March 22, 2022, 3:42pm UTC](https://forum.inductiveautomation.com/t/search-option-on-tag-tree/57462 "2022-03-22T15:42:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [March 22, 2022, 3:42pm UTC](https://forum.inductiveautomation.com/t/search-option-on-tag-tree/57462/1 "2022-03-22T15:42:22Z")

</div>

Hi  
I’m really struggling to implement a search option on the tag tree browser with progressive loading with no luck.  
I wonder if anyone developed this option on the tag tree?  
I want when user type chars in the search box, all the tree’s branches that have those chars, expand.

---

<div class="post-metadata">

**Author:** ![vasanth.p](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/vasanth.p/32/38099_2.png) [@vasanth.p](https://forum.inductiveautomation.com/u/vasanth.p)\
**Post date:** [November 3, 2022, 10:15am UTC](https://forum.inductiveautomation.com/t/search-option-on-tag-tree/57462/2 "2022-11-03T10:15:25Z")

</div>

[filterTest\_2022-11-03\_1517.zip](https://forum.inductiveautomation.com/uploads/short-url/uksEAPVPiAWcKkTEUpPbV74auJo.zip) (10.1 KB)

Even I am starting search option on Perspective tree,  
This can highlight the leaf with specific text.

Kindly suggest improvements.

---

<div class="post-metadata">

**Author:** ![Daniel\_Shevchyk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/daniel_shevchyk/32/48654_2.png) [@Daniel\_Shevchyk](https://forum.inductiveautomation.com/u/Daniel_Shevchyk)\
**Post date:** [November 6, 2023, 4:54pm UTC](https://forum.inductiveautomation.com/t/search-option-on-tag-tree/57462/3 "2023-11-06T16:54:26Z")

</div>

There are a few edge cases where this provided filter fails. There are times where the selection param adds unnecessary forward slashes in-between consecutive digits. You can fix this by capturing consecutive digits `op = re.findall(r"\d+", old)`:

```auto
	import re
	filteredItems = {}
	pyVals = system.util.jsonDecode(system.util.jsonEncode(self.getSibling("Tree").props.items))
#	system.util.jsonDecode(system.util.jsonEncode(self.getSibling("Tree").props.items))
	#system.perspective.print(type(pyVals))
#	system.perspective.print(system.util.jsonEncode(self.getSibling("Tree").props.items))
	def getKeys(val, old = '$'):
		if isinstance(val, dict):
			for k in val.keys():
				getKeys(val[k], old+ "." + str(k))
		elif isinstance(val, list):
			for i, k in enumerate(val):
				getKeys(k, old + "." + str(i))
		else:
			filterStr = self.getSibling("searchTextField").props.text
			#system.perspective.print(val)
			if old[-5:] == 'label' and filterStr in str(val):
				op = re.findall(r"\d+", old)
				filteredItems["/".join(op)] = str(val)
	
	getKeys(pyVals)
	sel = filteredItems.keys()
	selDict = {}
	
	for k, v in filteredItems.items():
		selDict['itemPath'] = k
		selDict['value'] = v
	system.perspective.print(sel)
	system.perspective.print(selDict)
	self.getSibling("Tree").props.selection = sel
	self.getSibling('Tree').props.selectionData = selDict

```

Not positive if this corrects all edge cases.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [November 7, 2023, 6:33am UTC](https://forum.inductiveautomation.com/t/search-option-on-tag-tree/57462/4 "2023-11-07T06:33:54Z")

</div>

Is it possible to post the full view that implements this? Maybe on Exchange?
