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