I have shown my datatable
jquery below.
$(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". Any ideas ???
Instead of disabling the button, don't bind it if StudentName
is Admin
. You can check StudentName
before bind buttons like below:
"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 '';
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.