How to filter treeview nodes when using local hierarchy data?

I have found the following document that describes how to implement filtering for a TreeView:


The data source provided in the example uses the self-referential model, however my data is structured in the hierarchy model. When I use the code provided in this example with my data the filtering only applies to top-level nodes of the TreeView and does not filter any subsequent levels. For example, given the following structure:

- Parent Node 1
     - A child node
     - Another child node
- Node 2
     - A child of parent

If I used the text "parent" (not case sensitive) I would expect to get back results showing "Parent Node 1" and "Node 2" because "Node 2" contains a  child node with "parent" in its title. Instead I only get back "Parent Node 1" because only the top-level nodes are filtered.

So, I guess my real question is how do I perform a filter on hierarchical data using the DataManager.executeLocal() method?

1 Reply

SP Sowmiya Padmanaban Syncfusion Team February 17, 2020 10:33 AM UTC

Hi Colin,  
 
Greetings from Syncfusion support. 
 
We have checked your reported query. Currently, we have filtering support only for the flat data source. Since the filtering of the hierarchical data source will be more complex.  
 
Though to achieve your requirement, you can try the following workaround suggestion. 
 
·       Expand all the nodes of TreeView nodes in search operation.  
 
·       Check the each li elements has search text.  
 
·       If present, set the display as block for that corresponding node and their parent nodes. 
 
·       set display as none for all TreeView Nodes which does not contain search text. 
 
You can try to achieve your requirement based on this  reference. If you face any issue while implementing. We will be happy to assist you. 
 
Please let us know, if you have need any further assistance. 
 
Regards,  
Sowmiya.P 


Loader.
Up arrow icon