@acorex/components 20.3.46 → 20.3.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1642,6 +1642,19 @@ class AXDataTableComponent extends AXBaseDataTable {
1642
1642
  this.displayedRows.set(data.items.filter((item) => !item[this.parentField]));
1643
1643
  this.totalRows = data.totalCount;
1644
1644
  this.hasItems = data.totalCount > 0;
1645
+ // When current page is beyond max valid page (e.g. after deleting last item on last page), navigate to previous page
1646
+ if (this.paging && data.totalCount > 0) {
1647
+ const pageSize = this.dataSource.pageSize;
1648
+ const maxPageIndex = Math.ceil(data.totalCount / pageSize) - 1;
1649
+ const currentPageIndex = this.page();
1650
+ if (currentPageIndex > maxPageIndex) {
1651
+ const newPageIndex = Math.max(0, maxPageIndex);
1652
+ this.page.set(newPageIndex);
1653
+ this.dataSource.setPage(newPageIndex);
1654
+ const pager = this.dataPager ?? this.customDataPager;
1655
+ pager?.goToPage(newPageIndex + 1);
1656
+ }
1657
+ }
1645
1658
  });
1646
1659
  this.dataSource.onItemExpanded.pipe(this._unsubscriber.takeUntilDestroy).subscribe((data) => {
1647
1660
  const { expandedItem, children } = data;