easyui中我们常获取树的节点信息进行拓展功能,那么如何进行获取节点信息呢?
1传入当前节点id,获取当前节点下的所有子节点,包括二级三级节点等等
function
getChildren(id
){
var
$tree = $(
'#tree'
);
var
node = $tree.tree(
'find'
,id);
var
childrenNodes = $tree.tree(
'getChildren'
,node.target);
return
childrenNodes;
}
2.获取当前节点的下一级节点
function
getSubChildren(id){
var
$tree = $(
'#tree'
);
var
node = $tree.tree(
'find'
,id);
var
subNodes = [];
$(node.target)
.next().children().children(
"div.tree-node"
).each(
function
(){
subNodes.push($tree.tree(
'getNode'
,
this
));
});
return
subNodes;
}