////////////////////////////////////////////////////////////////////
// @name :
// @description : function
// @params :
// @return :
////////////////////////////////////////////////////////////////////
function jstreeIterateNodes(
treeOwner ,
node ,
fnCallbackCondition ,
bRecursive ,
arrCollector
){
var
childNodes = node.children ,
arrCollector = ( arrCollector ) ? arrCollector : [] ,
bUseCallback = ( typeof fnCallbackCondition === "function" ) ? true : false ,
nodeItreator = null;
for(
var i = 0;
i < childNodes.length;
++i
){
nodeItreator = treeOwner.get_node( childNodes[i] );
if( bUseCallback ){
if( fnCallbackCondition( nodeItreator , node ) ){
arrCollector.push({
node : nodeItreator,
parent : node
});
}
}
if( bRecursive ){
jstreeIterateNodes(
treeOwner ,
nodeItreator ,
fnCallbackCondition ,
arrCollector
);
}
}
return arrCollector;
}
var
_your_jstree_ = $("#YOUR_TREE_ELEMENT").jstree( true ) ,
bRecursiveItreation = false , // could be true for recursive
arrCollected = null;
arrCollected = jstreeIterateNodes(
_your_jstree_ ,
_your_jstree_.get_node( "some_node_id" ) ,
function _your_filter_callback_( itrated_node , parent_itrated_node ){
// Do what ever and return true to collect
} ,
bRecursiveItreation
);
// DO SOMTHING WITH arrCollected which contains all collected nodes