Commit ffea53c0 authored by Jie Yuan's avatar Jie Yuan
Browse files

change paging of service table

parent cef5937a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@
</table>


 <mat-paginator [pageSizeOptions]="[10, 20,40]" showFirstLastButtons></mat-paginator>
 <mat-paginator [pageSize]="20" [pageSizeOptions]="getPageSizeOptions()" showFirstLastButtons></mat-paginator>
</div>

  </mat-sidenav-content>
+25 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ export class FulltableComponent implements OnInit , DoCheck, AfterViewInit{
  gocdbSiteNames: string[];
  dpmtSiteNames: string[];
  username: string;
  defaultPageSizeOptions: number[] =[10,20,40,80];
  
  @ViewChild(MatPaginator) paginator: MatPaginator;
  @ViewChild(MatSort) sort: MatSort;
@@ -373,4 +374,28 @@ export class FulltableComponent implements OnInit , DoCheck, AfterViewInit{
  }
  



getPageSizeOptions(): number[] {
  //console.log(this.dataSource.data.length);
  const real_length  = this.dataSource.data.length;
  var options = [1,2];
  options = [];
  for(var i = 0, len = this.defaultPageSizeOptions.length; i < len; i++){
   //console.log(this.defaultPageSizeOptions[i]);
    if ( this.defaultPageSizeOptions[i] <= real_length) {
      options.push(this.defaultPageSizeOptions[i]);
    } else {
      options.push(real_length);
      break;
    }
  }

  if ( i == this.defaultPageSizeOptions.length) {
    options.push(real_length);
  }
  //console.log(options);
  
  return options;
}
}