'Keep checkbox unchecked when it is disabled

I am using tree table in my angular app. My code is as follows:

<h5>Checkbox Selection</h5>
<p-treeTable
  [value]="files5"
  [columns]="cols"
  selectionMode="checkbox"
  [(selection)]="selectedNodes3"
>
  <ng-template pTemplate="caption">
    <div class="p-d-flex">
      <p-treeTableHeaderCheckbox></p-treeTableHeaderCheckbox>
      <span class="p-ml-2">Toggle All</span>
    </div>
  </ng-template>
  <ng-template pTemplate="header" let-columns>
    <tr>
      <th *ngFor="let col of columns">
        {{ col.header }}
      </th>
    </tr>
  </ng-template>
  <ng-template
    pTemplate="body"
    let-rowNode
    let-rowData="rowData"
    let-columns="columns"
  >
    <tr>
      <td *ngFor="let col of columns; let i = index">
        <p-treeTableToggler
          [rowNode]="rowNode"
          *ngIf="i == 0"
        ></p-treeTableToggler>
        <p-treeTableCheckbox
          [value]="rowNode"
          *ngIf="i == 0"
        ></p-treeTableCheckbox>
        {{ rowData[col.field] }}
      </td>
    </tr>
  </ng-template
</p-treeTable>

Stackoverflow:

https://stackblitz.com/edit/primeng-treetableselection-demo-yj7qay?file=src%2Fapp%2Fapp.component.html

Code is working fine. But even when I use [disabled] ton disable the checkbox, still it is getting checked. I want that when a checkbox is disabled then it should not be checked. How can I do that?



Solution 1:[1]

From the official documentation: TreeTable provides built-in single, multiple and checkbox selection features where selected rows are bound to the selection property and onRowSelect-onRowUnselect events are provided as optional callbacks. In order to enable this feature, define a selectionMode, bind a selection reference and add ttSelectableRow directive whose value is the rowNode to the rows that can be selected...

To disable selection events on a particular row use ttSelectableRowDisabled property.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roy Christo