1.Question Description:
ztree树各个节点都带有路径,如“/根节点”,"/根节点/一级节点",“根节点/一级节点/二级节点‘;
现在想获取所选的最末级节点数据集合。
2.Solution:
$("#btn_saveAssetInfo").click(function(){ var treeObj = $.fn.zTree.getZTreeObj("toggle"); var nodes = treeObj.getCheckedNodes(true); var asset_path = ""; for(var i=0;i<nodes.length;i++){ if(nodes[i].xpath != undefined ){ if((nodes[i].xpath).indexOf(asset_path.substring(0, asset_path.length-1))!=-1){ asset_path = nodes[i].xpath + ","; }else{ asset_path += nodes[i].xpath + ","; } } } });
如下图所示
一小片逻辑的叶子收藏一下 ,哈哈!!
时间: 2024-10-28 16:16:45