首页 > 代码库 > 分配角色测试脚本
分配角色测试脚本
<script type="text/javascript">
$(function () {
var treeGridOne = $("#treeGridOne");
var treeGridTwo = $("#treeGridTwo");
$.post("/Home/InitTree", function (data) {
var data1 = jQuery.parseJSON(data.split("#")[0]);
var data2 = jQuery.parseJSON(data.split("#")[1]);
treeGridOne.treegrid({
fit: true,
idField: ‘Guid‘,
treeField: ‘Name‘,
toolbar: ‘#toolBarIdOne‘,
singleSelect: true,
rownumbers: false,
data: data1
});
treeGridTwo.treegrid({
fit: true,
idField: ‘Guid‘,
treeField: ‘Name‘,
//url: ‘/Home/InitTree‘,
toolbar: ‘#toolBarIdTwo‘,
singleSelect: true,
rownumbers: false,
data: data1
});
$.each(data1, function (i, item1) {
$.each(data2, function (j, item2) {
console.log(item1.Guid)
console.log(item2.Guid)
if (item1.Guid == item2.Guid) {
alert("1"+ "#" + item1.Guid + "#" + item2.Guid)
$("#datagrid-row-r1-2-" + item1.Guid + "").hide();
$("#datagrid-row-r2-2-" + item1.Guid + "").show();
return false;
} else {
alert("2" + "#" + item1.Guid + "#" + item2.Guid)
$("#datagrid-row-r2-2-" + item1.Guid + "").hide();
}
})
})
$(‘#btn_setRoleOne‘).linkbutton({
onClick: function () {
var row = treeGridOne.treegrid("getSelected");
$("#datagrid-row-r1-2-" + row.Guid + "").hide();
$("#datagrid-row-r2-2-" + row.Guid + "").show();
}
});
$(‘#btn_setRoleTwo‘).linkbutton({
onClick: function () {
var row = treeGridTwo.treegrid("getSelected");
$("#datagrid-row-r1-2-" + row.Guid + "").show();
$("#datagrid-row-r2-2-" + row.Guid + "").hide();
}
});
})
})
</script>
分配角色测试脚本