简体   繁体   English

ngx-datatable 动态禁用或启用复选框

[英]ngx-datatable disable or enable the checkbox dynamically

I'm using a component ngx-datatable angular version 9. This component has the props [checkboxable]="true" to control the checkbox visibilit.我正在使用组件ngx-datatable angular 版本 9。该组件具有道具[checkboxable]="true"来控制复选框的可见性。

Problem: I need to control this props dynamicatly, like [checkboxable]=value .问题:我需要动态控制这个道具,比如[checkboxable]=value The "value" is a variable in component's TS. “值”是组件 TS 中的一个变量。 However I couldn't.然而我做不到。

Does anyone have any idea how to control it?有谁知道如何控制它?

Componet HTML:组件 HTML:

<ngx-datatable 
  class='material tableFix'
  [rows]='rows' 
  [columnMode]='"force"' 
  [headerHeight]="'auto'"
  [footerHeight]='50' 
  [externalPaging]="true" 
  [messages]="messageTable"
  [loadingIndicator]="loadingIndicator"
  [count]="pagination && pagination.total_record" 
  [offset]="pagination && pagination.page_number"
  [limit]="pagination && pagination.page_size"
  [rowHeight]="'auto'"
  [scrollbarH]="false"
  [selected]="selected"
  [selectionType]="'checkbox'"
  [displayCheck]="displayCheck"
  (page)="loadPagination($event)"
  (sort)="loadSort($event)">
  
  <ngx-datatable-column
    [width]="40"
    [sortable]="false"
    [draggable]="false"
    [resizeable]="false"
    [canAutoResize]="false"
    [headerCheckboxable]="true"
    [checkboxable]="true" headerClass="text-center" cellClass="text-center">
  </ngx-datatable-column>

In TS file you have to declare a variable like value ;在 TS 文件中你必须声明一个像value这样的变量;

value = true;价值=真;

In HTML在 HTML 中

Use [(checkboxable)] = "value" instead of [checkboxable]="true"使用 [(checkboxable)] = "value" 而不是 [checkboxable]="true"

Best regard!最良好的问候!

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

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