0

I'm using Angular 4 and I have a data table with more than 1000 rows of data. When ngOninit() is running, it takes a long time before I can see all the data! How can I make it faster? Or can I load the data page by page by using the [limit] and [offset] properties?

    <ngx-datatable *ngIf="showIncomingTable"
class="material selection-cell"
[rows]="rows"
[columnMode]="'force'"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="50"
[selected]="selected"
[selectionType]="'single'"
(activate)="onActivate($event)"
[limit]="10"
[offset]="page.pageNumber"
(page)='setPage($event)'>
<ngx-datatable-column prop="mail_number">
  <ng-template let-column="column" let-sort="sortFn" ngx-datatable-header-template>
    <span (click)="sort()" class="font">{{'IncomingTable.MailNumber' | translate}}</span>
  </ng-template>
  <ng-template let-value="value" ngx-datatable-cell-template>
    <span class="data_font">{{value}}</span>
  </ng-template>
</ngx-datatable-column>
</ngx-datatable>
Erik Humphrey
  • 345
  • 5
  • 18
fariba.j
  • 1,737
  • 7
  • 23
  • 42

1 Answers1

0

You can set paging on server side to load how many ever you want to show at a time. Look at this: How to use server side option in Angular DataTables with the Angular way example?

That would enhance the performance and loads the datatable faster

yer
  • 1,454
  • 2
  • 16
  • 33
  • well the data table that I'm using doesn't have the same options in the link that u say. I can set a limit and offset but when I do this, there I a long time data load and if I set a limit and offset from database queries, my data table pages won't be shown. – fariba.j Jun 08 '18 at 11:17