PrimeNG Table Lazy Loading with Server-Side Pagination State Synchronization
0 reputation · 13 Jul 2022, 14:40 UTC
Context
PrimeNG's p-table component supports lazy loading through the [lazy] input and (onLazyLoad) event emitter. When enabled, the component delegates data fetching to the application, passing a LazyLoadEvent object containing first (offset) and rows (page size) values. The integrated p-paginator updates these values automatically on user interaction.
Unresolved Configuration
Applications using server-side pagination must decide how to synchronize the table's internal pagination state with the backend response. The first and rows properties can be bound as inputs, but the component also maintains its own state when the paginator is used. If the backend returns a different total record count than expected, or if the page size changes dynamically, the paginator UI may display incorrect page numbers or disabled navigation controls.
Specific Questions
- Should the
firstandrowsproperties be treated as one-way inputs or two-way bindings when using a custom paginator template? - How does the table reconcile its internal
firstvalue when theonLazyLoadhandler fetches a page that the backend rejects due to an out-of-range offset? - Is there a documented pattern for resetting pagination to the first page after a filter or sort change without triggering a redundant
onLazyLoadcall?