我使用角度4,我有一个包含超过1000行数据的数据表。当ngOninit()运行时,我需要很长时间才能看到所有数据!如何让它更快或者我可以通过使用限制和偏移来逐页加载数据?
<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>
答案 0 :(得分:0)
您可以在服务器端设置分页,以加载您希望一次显示的内容。看这个: How to use server side option in Angular DataTables with the Angular way example?
这样可以提高性能并加快数据表的加载速度