1)与分组,totalRecords
你设置不正确。我们必须计算标题行的数量并将其添加到totalRecords
:
this.totalRecords = this.filteredInvoices.length + Object.keys(this.rowGroupMetadata).length;
2)总是从头开始切片对我来说不太有意义。我们应该只将新行推送到表中。所以而不是:
loadChunk(init?: boolean) {
...
data = [...this.filteredInvoices]
} else {
data = this.filteredInvoices.slice(0, endIndex); // <===
}
..
}
你可以这样做:
loadChunk(init?: boolean) {
...
const startAt = this.displayedInvoices ? this.displayedInvoices.length : 0;
let endAt = startAt + this.MAX_ROWS;
if (endAt >= this.filteredInvoices.length) {
endAt = this.filteredInvoices.length;
}
const newInvoices = this.filteredInvoices.slice(startAt, endAt);
this.displayedInvoices.push(...newInvoices);
}
更新了您的 blizz,希望对您有所帮助:https ://stackblitz.com/edit/angular6-primeng-psbm78?file=src/app/home-encoding/home-encoding.component.ts
干杯克里斯