Custom search for jQuery FancyTree plugin
Asked Answered
G

2

5

I'm using the FancyTree jQuery plugin in one of my projects: https://github.com/mar10/fancytree

This plugin also has a Filter extension which either dimms or hides the unmatched nodes: https://github.com/mar10/fancytree/wiki/ExtFilter

My tree is a two-level tree, it means that there are folders which have children. What I try to do is - search by both Folder name and nodes names. The problem is that when you have something like this:

Node Title - Node child - Node child 2

Searching by "Title" will leave the folder "Node Title" and hide the children since there's no "Title" in them.

What I want to do is - search by both folder name and children names but don't hide the children - hide the unmatched folders only.

So, when you search by "Title" - it will hide all the folders which do not have "Title" in them but leave the child nodes of "Node Title" folder intact - visible.

Could anybody help me with an advise on how can this be done?

Thanks beforehand!

Geochronology answered 8/5, 2014 at 13:32 Comment(0)
Z
6

This new feature has just been implemented: https://github.com/mar10/fancytree/wiki/ExtFilter

Look for the tree.filterBranches(filter) method.

Zita answered 10/5, 2014 at 20:53 Comment(0)
M
1

I had exactly the same problem and google brought me here. It took me some time to understand this answer. You have to replace the filterNodes(...) in the sample with filterBranches(...). The internal function can stay exactly the same.

Mady answered 15/9, 2014 at 8:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.