Reputation: 115
How can I apply sorting in Material table with conditional checkboxes:
<ng-container matColumnDef="key">
<mat-header-cell *matHeaderCellDef mat-sort-header> Key </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.key}} </mat-cell>
</ng-container>
Upvotes: 0
Views: 1011
Reputation: 1997
You can solve this by setting your datasource a custom sortingDataAccesor.
this.dataSource.sortingDataAccessor = (object, columnDef) => {
switch(columnDef) {
case 'key':
return object.yourValue ? 1 : 0;
default:
break;
}
}
Upvotes: 1