ztree的一个小功能 - 显示节点的数目
作者:互联网
var setting={ view: { dblClickExpand: false, showLine: true, selectedMulti: false, showIcon:false }, edit:{
enable: true, showRemoveBtn: false, showRenameBtn: false }, data: { simpleData: { enable: true, idKey: "id", pIdKey: "pid", rootPId: "" } }, callback: { // onRightClick: OnRightClick, // onNodeCreated: zTreeOnNodeCreated, onClick: zTreeOnClick, } };var zTreeObj = $.fn.zTree.init($("#ztree_risk"), setting, data); var nodesLists = zTreeObj.getNodes(); getNum(nodesLists); //展示获取子节点的数目 function getNum(paramLists){ for (var i=0, l=paramLists.length; i<l; i++) { var num = paramLists[i].children ? paramLists[i].children.length : 0; paramLists[i].name = paramLists[i].name.replace(/ \(.*\)/gi, "") + " (" + num + ")"; zTreeObj.updateNode(paramLists[i]); if(num>0){ getNum(paramLists[i].children) }; } };
标签:false,true,data,getNum,ztree,var,paramLists,数目,节点 来源: https://www.cnblogs.com/fyjz/p/12852461.html