[英]How to disable the render function in jquery datatable with condition?
I have shown my datatable
jquery below.我已经表明我的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',
);
});
Here i want to disable the buttons
(Details,Edit) inside the <a>
tag when the studentName
is "Admin".在这里,当studentName
为“Admin”时,我想禁用<a>
标签内的buttons
(详细信息、编辑)。 Any ideas ???有任何想法吗 ???
Instead of disabling the button, don't bind it if StudentName
is Admin
.如果StudentName
是Admin
,不要禁用按钮,而不是禁用它。 You can check StudentName
before bind buttons like below:您可以在绑定按钮之前检查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.