Custom search for jQuery FancyTree plugin

。_饼干妹妹 提交于 2019-12-10 13:56:33

问题


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!


回答1:


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

Look for the tree.filterBranches(filter) method.




回答2:


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.



来源:https://stackoverflow.com/questions/23543283/custom-search-for-jquery-fancytree-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!