Browse Source

Fix pagination issue in ExtensibleTableComponent

pull/19203/head
Sinan Öztürk 3 years ago
parent
commit
5e68a58b5f
  1. 14
      npm/ng-packs/packages/components/extensible/src/lib/components/extensible-table/extensible-table.component.ts
  2. 2
      npm/ng-packs/packages/core/src/lib/services/list.service.ts

14
npm/ng-packs/packages/components/extensible/src/lib/components/extensible-table/extensible-table.component.ts

@ -175,7 +175,19 @@ export class ExtensibleTableComponent<R = any> implements OnChanges {
);
}
ngOnChanges({ data }: SimpleChanges) {
ngOnChanges({ data, recordsTotal }: SimpleChanges) {
if (data?.currentValue.length === 0 && recordsTotal?.currentValue) {
console.log(recordsTotal?.currentValue);
let maxPage = Number(Number(recordsTotal?.currentValue / this.list.maxResultCount).toFixed());
if(recordsTotal?.currentValue % this.list.maxResultCount === 0){
maxPage -= 1;
}
this.list.page = maxPage;
return;
}
if (!data?.currentValue) return;
if (data.currentValue.length < 1) {

2
npm/ng-packs/packages/core/src/lib/services/list.service.ts

@ -150,7 +150,7 @@ export class ListService<QueryParamsType = ABP.PageQueryParams | any> implements
this._query$.next({
filter: this._filter || undefined,
maxResultCount: this._maxResultCount,
skipCount: this._filter ? 0 : this._page * this._maxResultCount,
skipCount: this._page * this._maxResultCount,
sorting: this._sortOrder ? `${this._sortKey} ${this._sortOrder}` : undefined,
} as any as QueryParamsType);
}

Loading…
Cancel
Save