[英]How to disable the render function in jquery datatable with condition?
我已經表明我的datatable
下面的jQuery。
$(document).ready(function () {
DataTable(
'StudentDetails',
'student Details',
[
{ "data": "StudentName", "name": "StudentName", "autoWidth": true },
{
"orderable": false,
"searchable": false,
"className": 'text-right',
"render": function (data, type, full, meta) {
return '<a class="btn" href="UserLevels/' + full.StudentName+ '">Details</button>' +
'<a class="btn" href = "UserLevels/' + full.StudentName+ '/Edit">Edit</a>';
}
}
],
[
],
'StudentDetails/LoadData',
);
});
在這里,當studentName
為“Admin”時,我想禁用<a>
標簽內的buttons
(詳細信息、編輯)。 有任何想法嗎 ???
如果StudentName
是Admin
,不要禁用按鈕,而不是禁用它。 您可以在綁定按鈕之前檢查StudentName
,如下所示:
"render": function(data, type, full, meta) {
if (full.StudentName != 'Admin') {
return '<a class="btn" href="UserLevels/' + full.StudentName + '"> Details </button>' +
'<a class="btn" href = "UserLevels/' + full.StudentName + '/Edit"> Edit </a>';
} else
return '';
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.