var treeNodeIds="";//获得所有树节点的id
function aa(){
var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
var nodes = treeObj.getNodes();
treeNodeIds += nodes[0].id; //获取首节点的id
if(nodes[0].children!=undefined){//当前节点包含子节点
getNodesId(nodes[0].children);//获取当前节点的子节点的id
}
alert(treeNodeIds);
};
function getNodesId(nodes){
for(var j=0;j<nodes.length;j++){
treeNodeIds += ","+nodes[j].id;//当前节点id
if(nodes[j].children!=undefined){//当前节点包含子节点
getNodesId(nodes[j].children);//递归,获取当前节点的子节点的id
}
}
}