I have Mat table with a checkbox column. I am setting certain checkboxes to disabled based on certain conditions. However the user is still able to select the checkbox if the click on the row. How do I prevent the checkbox from being selected when disabled: Here is a stackblitz example I forked from the material design site: https://stackblitz.com/edit/angular-erpaus?file=app%2Ftable-selection-example.html. you can't click the check box but if you click outside of it the checkbox gets selected:
<mat-checkbox (click)= "$event.stopPropagation()"
(change)="$event ? selection.toggle(row) :null"
[checked]="selection.isSelected(row)"
[disabled]="myCondition"
color="primary">
</mat-checkbox>
Aucun commentaire:
Enregistrer un commentaire