Ajout du tri du tableau de la litse des notes

develop
Yanaël GRETTE 4 years ago
parent 9bb818d684
commit 7aca2a5165
  1. 8
      src/app/notes/notes.component.html
  2. 17
      src/app/notes/notes.component.ts

@ -21,20 +21,20 @@
<ng-container *ngIf="taille != 0">
<mat-table [dataSource]="dataSource">
<mat-table [dataSource]="dataSource" (matSortChange)="triTableau($event)" matSort matSortActive="{{this.tri}}" matSortDirection="desc">
<ng-container matColumnDef="collaborateur">
<mat-header-cell *matHeaderCellDef>Collaborateur</mat-header-cell>
<mat-header-cell *matHeaderCellDef mat-sort-header disableClear>Collaborateur</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.collaborateur }}</mat-cell>
</ng-container>
<ng-container matColumnDef="titre">
<mat-header-cell *matHeaderCellDef>Titre</mat-header-cell>
<mat-header-cell *matHeaderCellDef mat-sort-header disableClear>Titre</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.titre }}</mat-cell>
</ng-container>
<ng-container matColumnDef="datemiseajour">
<mat-header-cell *matHeaderCellDef>Dernière mise à jour</mat-header-cell>
<mat-header-cell *matHeaderCellDef mat-sort-header disableClear>Dernière mise à jour</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.dateMiseAJour | date : 'dd/MM/yyyy à hh:mm'}}</mat-cell>
</ng-container>

@ -14,13 +14,13 @@ export class NotesComponent implements OnInit {
displayedColumns : string[] = ["collaborateur", "titre", "datemiseajour"];
chargement: boolean = true;
asc: boolean = true;
asc: boolean = false;
numPage: number = 1;
parPage: number = 15;
tri: string = "";
tri: string = "datemiseajour";
search: string = "";
@ -82,6 +82,19 @@ export class NotesComponent implements OnInit {
this.updateDataSource();
}
triTableau(e) {
this.tri = e.active;
switch(e.direction) {
case "asc":
this.asc = true;
break;
case "desc":
this.asc = false;
break;
}
this.updateDataSource();
}
ngOnDestroy() {
if(this.notesSubscriber != undefined) {

Loading…
Cancel
Save