DataTables server-side pagination: no automatic page reset when total records decrease
0 reputation · 31 Jul 2022, 17:52 UTC
Goal
Ensure that a DataTable using server‑side pagination remains usable when the total record count reported by the server decreases between requests, avoiding an empty table view while preserving meaningful pagination controls.
Constraints and uncertainty
DataTables calculates the start index solely from the current page number and page length, sending it to the server without checking whether the start exceeds the newly supplied recordsTotal. When start > recordsTotal the library shows zero rows but leaves the pagination controls on the same page index, and there is no configuration option or version‑specific change (in 1.10.x or the 2.0.0 alpha) that automatically resets the start index or redirects to the first page. This places the burden on the server implementation to detect out‑of‑range requests and either return an empty data set with a corrected start or provide the first page of data.
Is there a built‑in configuration flag or API method to force DataTables to revert to the first page when the start index exceeds recordsTotal? Does the upcoming DataTables 2.0.0 release introduce any automatic start‑correction behavior? Should implementers rely on server‑side logic to return the first page of data whenever start > recordsTotal, or is a client‑side workaround preferred?