Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用条件禁用jquery datatable中的render函数?_Javascript_Jquery_Datatables - Fatal编程技术网

Javascript 如何使用条件禁用jquery datatable中的render函数?

Javascript 如何使用条件禁用jquery datatable中的render函数?,javascript,jquery,datatables,Javascript,Jquery,Datatables,我已经在下面显示了我的datatablejquery $(document).ready(function () { DataTable( 'StudentDetails', 'student Details', [ { "data": "StudentName", "name": "StudentName", "autoWidth": true }, { "orderable": false,

我已经在下面显示了我的
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',
            );
        });
$(文档).ready(函数(){
数据表(
"学生资料",,
"学生资料",,
[
{“data”:“StudentName”,“name”:“StudentName”,“autoWidth”:true},
{
“可订购”:错误,
“可搜索”:错误,
“className”:“文本权限”,
“呈现”:函数(数据、类型、完整、元){
返回“”;
}
}
],
[
],
“StudentDetails/LoadData”,
);
});
在这里,当
studentName
为“Admin”时,我想禁用
标记内的
按钮(详细信息,编辑)。

有什么想法吗?

如果
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 '';
}
“呈现”:函数(数据、类型、完整、元){
if(full.StudentName!=“Admin”){
返回“”;
}否则
返回“”;
}

只需使用三元基本条件,然后将此代码$('disableanchor').attr(“disabled”,“disabled”);