var treeObj = $.fn.zTree.getZTreeObj(treeid); var data = $("#hiddentree"+'${model.objUid}').val(); var datas = data.split(','); var inputtree = ''; var d = ''; for(var i = 0;i<datas.length;i++){ treeObj.checkNode(treeObj.getNodesByParam("id", datas[i],null)[0],true, true); inputtree += treeObj.getNodesByParam("id", datas[i],null)[0].name+","; d = inputtree.substring(0,inputtree.length-1); $("#inputtree"+'${model.objUid}').val(d); } 注:treeid:tree的ID treeObj:tree对象 treeObj.getNodesByParam("id", datas[i],null)[0] 根据键值获取相应的节点,[0]获取第一个object就是你需要的数据节点 treeObj.checkNode(nodes,true,true)checkNode方法根据相应节点,进行勾选 treeObj.getNodesByParam("id", datas[i],null)[0].name 获取节点数据的相应的属性
时间: 2024-10-10 10:29:37