I am using this URL and I am doing sorting. Sorting is working fine but, I have 2 numeric column
I need to apply sorting in "Double weight" column. Can someone please guides me on this.
HTML
< ng-container matColumnDef="weight">
< th mat-header-cell *matHeaderCellDef mat-sort-header> Weight
< td mat-cell *matCellDef="let element"> {{element.weight}}
< /ng-container>
< ng-container matColumnDef="weight2">
< th mat-header-cell *matHeaderCellDef mat-sort-header> Weight
< td mat-cell *matCellDef="let element"> {{element.weight * 2}}
< /ng-container>
TS
@ViewChild(MatSort) sort: MatSort;
ngOnInit() {
this.dataSource.sort = this.sort;
}
I'm pretty sure that sorting on (weight * 2) will give exactly the same result as sorting by weight.
So while you display different values in the two columns, just sort on weight in both cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With