"Sort" sur les tableaux et listes déroulantes.

This commit is contained in:
Sébastien André
2021-04-22 14:29:22 +02:00
parent a2ea873ae3
commit 6f7b439e56
8 changed files with 19 additions and 13 deletions

View File

@@ -18,7 +18,6 @@ import { NewDropZoneComponent } from '../new-drop-zone/new-drop-zone.component';
export class ListOfDzsComponent implements OnInit {
public displayedColumns: Array<string> = [
'isfavorite',
'id',
'name',
'address',
'type',
@@ -49,7 +48,7 @@ export class ListOfDzsComponent implements OnInit {
private getListOfDropZones() {
this.serviceApi.getListOfDropZones().subscribe((data) => {
setTimeout(() => {
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0));
data.sort((a, b) => (b.isFavorite ? 1 : 0) - (a.isFavorite ? 1 : 0) || a.name.localeCompare(b.name));
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
this.dataSourceTable.paginator = this.paginator;
this.resultsLength = data.length;