Layui 获取树全部选中的节点ID
话不多说直接上代码
//监听授权按钮 form.on('submit(Authorization)', function (data) { var userid = document.getElementById("UserId").value; var checkedData = tree.getChecked('ActorTreeid'); //获取选中节点的数据 var nodeIds = new Array(); nodeIds = getCheckedId(checkedData); var ActorTreeid = nodeIds;//JSON.stringify(nodeIds) $.ajax({ type: 'POST', url: '../handler/User_Actor.ashx', data: { "userid": userid, "ActorTreeid": ActorTreeid }, success: function (date) { var result = date; if (result == "1" || result == "2") { layer.msg("授权成功!", { icon: 6 }); } else { layer.msg("授权失败!" + result, { icon: 5 }); } }, dataType: "json", error: function (err) { layer.msg("授权失败!" + err, { icon: 5 }); } }); return false; }); //获取所有选中的节点id function getCheckedId(data) { var id = ""; $.each(data, function (index, item) { if (id != "") { id = id + "$" + item.id; } else { id = item.id; } //item 没有children属性 if (item.children != null) { var i = getCheckedId(item.children); if (i != "") { id = id + "$" + i; } } }); return id; }