Sort players by id
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
<input matInput (keyup)="filterPlayersList($event)" #input>
|
||||
</mat-form-field>
|
||||
<div>
|
||||
<table mat-table [dataSource]="dataSource" matSort matSortActive="name" matSortDirection="asc">
|
||||
<ng-container matColumnDef="position">
|
||||
<th mat-header-cell *matHeaderCellDef>#</th>
|
||||
<table mat-table [dataSource]="dataSource" matSort matSortActive="id" matSortDirection="asc">
|
||||
<ng-container matColumnDef="id">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>#</th>
|
||||
<td mat-cell *matCellDef="let player">{{ player.id }}</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="name">
|
||||
|
||||
@@ -34,7 +34,7 @@ export class PlayerListComponent implements AfterViewInit {
|
||||
|
||||
players: Player[];
|
||||
|
||||
displayedColumns: string[] = ['position', 'name', 'sex', 'club', 'action'];
|
||||
displayedColumns: string[] = ['id', 'name', 'sex', 'club', 'action'];
|
||||
dataSource: MatTableDataSource<Player>
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
@@ -53,9 +53,9 @@ export class PlayerListComponent implements AfterViewInit {
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sortingDataAccessor = (item, header) => {
|
||||
switch (header) {
|
||||
case 'id': return item.id;
|
||||
case 'club': return item.club;
|
||||
default: return item.lastName + item.firstName;
|
||||
// case 'name': return this.fullNamePipe.transform(item);
|
||||
}
|
||||
}
|
||||
this.dataSource.sort = this.sort;
|
||||
|
||||
Reference in New Issue
Block a user