ztree获取当前节点下的所有子节点id

var setting = {

data: {

simpleData: {

enable: true

}

},

view: {

showIcon: false

},

callback:{

onClick:function zTreeOnClick(event, treeId, treeNode){

   alert(treeNode.tId + ", " + treeNode.name+", "+treeId);

   var ids=[];

   ids=getChildren(ids,treeNode);

   

}

 

},

check: {

enable: true,

autoCheckTrigger:false,

chkboxType:{ "Y":"ps", "N":"ps" }

}

};

 

//ids是一个数组 返回结果数组     treeNode是选中的节点

function getChildren(ids,treeNode){

ids.push(treeNode.id);

if (treeNode.isParent){

for(var obj in treeNode.children){

getChildren(ids,treeNode.children[obj]);

}

   }

return ids;

}

你可能感兴趣的:(ztree)