$.parser.onComplete = function (context) { var roleData = eval("(" + $("[name='hidRoleData']").val() + ")"); var departmentData = eval("(" + $("[name='hidDepartmentData']").val() + ")"); $("#dgRoleList").cmsXDataTable("loadData", { rows: roleData, total: roleData.length }); if (departmentData!=null) { $("#dgDepartmentList").cmsXDataTable("loadData", { rows: departmentData, total: departmentData.length }); } changeRoleType(); changeCollegeType(); } function changeRoleType() { var isChecked = $("[name='RoleType']:checked").length > 0; var roleTypeCheckbox = $("[name='RoleType']"); if (isChecked) { roleTypeCheckbox.parent().parent().next().find("*").attr("disabled", "disabled"); } else { roleTypeCheckbox.parent().parent().next().find("*").removeAttr("disabled") } } function changeCollegeType() { var isChecked = $("[name='CollegeType']:checked").length > 0; var collegeTypeCheckbox = $("[name='CollegeType']"); if (isChecked) { collegeTypeCheckbox.parent().parent().next().find("*").attr("disabled", "disabled"); } else { collegeTypeCheckbox.parent().parent().next().find("*").removeAttr("disabled") } } function SOCDoc_Save() { $(document.forms[0]).submit(); } function getSelectedRole() { var d = []; $.each($("#dgRoleList").cmsXDataTable("getSelections"), function (index) { d.push(this.RoleID); }); return d; } function SOCDocRole_Add() { $.popupTopWindow('选择角色', CMS_SystemConfig.VirtualDirectoryPath + '/Common/RoleSelector', 400, 250, SOCDocRole_Add_Confirm); } function SOCDocRole_Add_Confirm(data) { if (data) { var roleData = $("#dgRoleList").cmsXDataTable("getRows"); $.each(data, function (i, v) { roleData.push({ RoleID: v.RoleID, RoleName: v.RoleName }); }); $("#dgRoleList").cmsXDataTable("loadData", { rows: roleData, total: roleData.length }); } } function SOCDocRole_Delete() { var selectedIDList = getSelectedRole(); var roleData = $("#dgRoleList").cmsXDataTable("getRows"); roleData = $.grep(roleData, function (x) { return !selectedIDList.contains(x.RoleID) }); $("#dgRoleList").cmsXDataTable("loadData", { rows: roleData, total: roleData.length }); } function getSelectedCollege() { var d = []; $.each($("#dgDepartmentList").cmsXDataTable("getSelections"), function (index) { d.push(this.DepartmentID); }); return d; } function SOCDocCollege_Add() { $.popupTopWindow('选择部门', CMS_SystemConfig.VirtualDirectoryPath + '/Common/DepartmentSelector', 800, 600, SOCDocCollege_Add_Confirm); } function SOCDocCollege_Add_Confirm(data) { if (data) { var departmentData = $("#dgDepartmentList").cmsXDataTable("getRows"); $.each(data, function (i, v) { departmentData.push({ DepartmentID: v.DepartmentID, Name: v.Name }); }); $("#dgDepartmentList").cmsXDataTable("loadData", { rows: departmentData, total: departmentData.length }); } } function SOCDocCollege_Delete() { var selectedIDList = getSelectedCollege(); var departmentData = $("#dgDepartmentList").cmsXDataTable("getRows"); departmentData = $.grep(departmentData, function (x) { return !selectedIDList.contains(x.DepartmentID) }); $("#dgDepartmentList").cmsXDataTable("loadData", { rows: departmentData, total: departmentData.length }); }