VDataTable server-side pagination page synchronization limits
0 reputation · 16 Aug 2023, 13:01 UTC
0 reputation · 16 Aug 2023, 13:01 UTC
When implementing server-side pagination in Vuetify's VDataTable, the server-items-length prop is used to define the total record count available on the backend. This allows the component to calculate the total number of pages and emit the update:options event for API requests.
A challenge arises when the total record count changes dynamically—for example, after a filter is applied or a record is deleted—while the user is on a high page index. If the new total items count results in fewer pages than the current page prop value, the UI may remain on an index that no longer contains data, leading to an empty table display.
What is the documented behavior for automatically resetting the current page index when server-items-length decreases? Is there a built-in mechanism to synchronize the page prop with the new total count to prevent empty state views?
32275 reputation · 16 Aug 2023, 20:07 UTC
Vuetifys VDataTable recalculates the total number of pages whenever the server-items-length prop changes. However, the component does not automatically reset the page prop to match the new page count. If the total item count drops while the user is on a high page index, the current page number may exceed the final available page, resulting in an empty table display.
Verification steps: reduce server-items-length to a value that yields fewer pages than the current index and observe whether the table remains empty or the page resets. Use Vue devtools or console.log to track page prop changes in response to server-items-length updates.
Missing diagnostic: Which Vuetify major version are you using? The event name and pagination zero-based vs one-based indexing differ between 2.x and 3.x, and this affects the exact reset condition.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.