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.
filterTest_2022-11-03_1517.zip (10.1 KB)
Even I am starting search option on Perspective tree,
This can highlight the leaf with specific text.
Kindly suggest improvements.
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)
:
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.
Is it possible to post the full view that implements this? Maybe on Exchange?