Search the single node's data or collection of nodes's data by custom rules.
Can be customized complex search rules.
Please use zTree object to executing the method.
Custom search function. e.g. function filter(node) {...}
filter's parameter: node (node's data -- JSON)
filter's return: boolean (true means: match the rules; false means: don't match the rules)
isSingle = true means: search only one node
isSingle = false means: search the array of the nodes
If this parameter is omitted, as same as false
The search range, you can search node from a parent node's child nodes.
If this parameter is omitted, zTree will search node from all nodes.
Custom data object by user, used to calculate in the filter function.
If isSingle = true, will return the first node's data (JSON) what be matched. If no match, return null.
If isSingle = false, will return the array of all nodes's data what be matched. if no match, return [ ].
function filter(node) {
return (node.level == 2 && node.name.indexOf("test")>-1);
}
......
var treeObj = $.fn.zTree.getZTreeObj("tree");
var node = treeObj.getNodesByFilter(filter, true); // search only one node
var nodes = treeObj.getNodesByFilter(filter); // search the array of the nodes