I'm struggling from 2 days on this problem in my angular2+bootstrap+material project.
I need to change the material design checkbox:
- When i check a checkbox from my table, that check have to be the only one
I know that i can use a material radio button, but in that case i have another problem : i can't uncheck the radio button.
So i need to enable unique check and also check/uncheck functions.
I've tried the following
- Interact with dom with document.getElement.blablabla
- Used dom interpolation of angular 2
- Javascript function
- Jquery function
Here's the code of html:
<div class="row">
<div class="col-lg-12">
<label>Ordini cliente</label>
<mat-table #table [dataSource]="dataSource">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" -->
<!-- Select Column -->
<ng-container matColumnDef="Select">
<mat-header-cell *matHeaderCellDef></mat-header-cell>
<mat-cell *matCellDef="let item"><mat-checkbox color="primary"></mat-checkbox></mat-cell>
</ng-container>
//OTHER COLUMNS ...
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
</div>
My idea was to bind the element to a click event like this
<mat-cell *matCellDef="let item"><mat-checkbox (click)="foo()" color="primary"></mat-checkbox></mat-cell>