【问题标题】:How to disable row checkbox based on the cell value in Datatables jquery如何根据Datatables jquery中的单元格值禁用行复选框
【发布时间】:2021-02-21 02:52:09
【问题描述】:

如何根据数据表中的单元格值禁用行复选框。有表,少数列有像 System.如果是系统需要禁用该行。试过下面的代码,复选框没有被禁用。

this.dtOptions = {
  ajax: 'assets/test.json',
  initComplete: function (settings, json) {
    $.each(json.data, function (index, value) {  
      if(value.matchType == "System"){ //working
        $("table").closest('tbody tr td').find('input:checkbox').prop('disabled', true);
      } 
  }); 
  },

【问题讨论】:

  • 在您比较单元格值的代码中?
  • 在条件语句中 if(value.matchType == "System")

标签: jquery angularjs datatables


【解决方案1】:

我是你的代码,如果 index 是你的行索引,那么你可以试试这个

this.dtOptions = {
  ajax: 'assets/test.json',
  initComplete: function (settings, json) {
    $.each(json.data, function (index, value) {  
      if(value.matchType == "System"){ //working
        $("table tr").eq(index).find('input:checkbox').prop('disabled', true);
      } 
  }); 
  },

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 2017-06-20
    • 1970-01-01
    相关资源
    最近更新 更多