我有一个jQuery数据表,设置如下。我在document.ready函数中使其可编辑。我试图根据当前登录用户的角色控制添加/删除/更新功能。我可以通过为这两个按钮添加禁用属性来执行添加/删除操作。在document.ready函数中,我有一个函数EnableUserAddDeleteButtons(),它将检查用户的角色,并通过删除属性“disabled”(如果它是授权用户)来启用按钮。但我不确定如何在用户未获得授权时将所有单元格设置为只读。有任何想法吗?谢谢你的帮助。
<script type="text/javascript">
$(document).ready(function () {
$('#UserDataTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
}).makeEditable({
"aoColumns": [{}, {}, {}, {},
{
type: 'select',
onblur: 'submit',
data: "{'True':'True', 'False':'False'}"
},
{
type: 'select',
onblur: 'submit',
data: "{'True':'True', 'False':'False'}"
},
{
type: 'select',
onblur: 'submit',
data: "{'True':'True', 'False':'False'}"
}],
sUpdateURL: "/Admin/UpdateUser"
sAddURL: "/Admin/InsertUser"
sDeleteURL: "/Admin/DeleteUser"
sAddNewRowFormId: "formAddNewUser",
sAddNewRowButtonId: "btnAddNewUser",
sAddNewRowOkButtonId: "btnAdd",
sAddNewRowCancelButtonId: "btnCancel",
sDeleteRowButtonId: "btnDeleteUser",
fnShowError: function (message, action) {
switch (action) {
case "update":
jAlert(message, "Update failed");
break;
case "delete":
jAlert(message, "Delete failed");
break;
case "add":
$("#lblAddError").html(message);
$("#lblAddError").show();
break;
}
},
fnStartProcessingMode: function () {
$("#processing_message").dialog();
},
fnEndProcessingMode: function () {
$("#processing_message").dialog("close");
}
});
EnableUserAddDeleteButtons();
});
</script>