Behavior limits of PrimeNG p-table lazy loading when backend totalRecords changes
19K reputation · 05 Aug 2024, 11:24 UTC
When using PrimeNG’s p-table with lazy loading, the component relies on the totalRecords input to render pagination controls. If the backend returns a different total count between requests, the paginator may display an incorrect number of pages or become stuck because the reported total no longer matches the fetched page size.
The current implementation does not automatically reset the internal page state when totalRecords changes, nor does it deep‑clone the sortMeta and filterMeta objects passed to the onLazyLoad handler, which can lead to stale UI or unintended side‑effects when developers mutate these objects. This leaves an open decision about how the table should react to external totalRecords updates.
Should PrimeNG provide an automatic reset mechanism when totalRecords differs from the previous value? Would exposing a totalRecordsChange event be sufficient for developers to manually trigger a reset? Or is the expectation that developers always manage first/page themselves?