繁体   English   中英

Angular 数据表:如何根据列数据禁用立即行复选框

[英]Angular Datatable: How to disable immediate row checkbox based on the column data

如何根据列数据禁用行复选框。 有一个数据表并且必须写一个条件,如果firstname="Superman",需要disable checkbox of the row. 所以不可能再次选择 select 复选框。 我尝试使用下面的代码,但我无法禁用该复选框。 我试过下面的代码,

this.http.get(dataUrl).subscribe(response => {
  // setTimeout(() => {
  this.persons = response.data;
  $.each(this.persons, function(key, value) {
    if (value.firstname == "Superman") {
      console.log("inside");
      // $('.checkboxCls').prop('disabled', true);
      $(this)
        .closest("tr")
        .find("input[type=checkbox]")
        .prop("disabled", true);
    }
  });
  this.dtTrigger.next();
  // });
});

这是工作中的Stackblitz供参考。 您能否提出问题所在。

您可以从 HTML 模板端禁用该复选框。

    <td><input [disabled]="person.firstName === 'Superman'" type="checkbox" class="checkboxCls" name="id" [checked]="isChecked" value="{{person.id}}"></td>

编辑StackBlitz代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM