function getRoot() {
var treeObj = $.fn.zTree.getZTreeObj("tree-div");
//返回一個根節點
var node = treeObj.getNodesByFilter(function (node) { return node.level == 0 }, true);
}
function getRoots() {
var treeObj = $.fn.zTree.getZTreeObj("tree-div");
//返回根節點集合
var nodes = treeObj.getNodesByFilter(function (node) { return node.level == 0 });
}
//獲取當前節點的根節點(treeNode為當前節點)
function getCurrentRoot(treeNode){
if(treeNode.getParentNode()!=null){
var parentNode = treeNode.getParentNode();
return getCurrentRoot(parentNode);
}else{
return treeNode.id;
}
}
