vuetify: [Bug Report][3.3.11] VDataTable - Unable to set initial page
Environment
Vuetify Version: 3.3.11 Vue Version: 3.3.4 Browsers: Firefox 117.0 OS: Linux x86_64
Steps to reproduce
Set the page prop to something other than 1. (e.g. from a URL query parameter)
Expected Behavior
Table displays the given page of the table.
Actual Behavior
The page prop is always changed back to 1 on load.
Reproduction Link
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 17
- Comments: 17 (3 by maintainers)
Commits related to this issue
- :sparkles: Make url query params sync with table query. NOTE: Use of v-skeleton-loader. If you don't do this the v-data-table-server component will reset the page value on load. See https://github.co... — committed to icefoganalytics/internal-data-portal by klondikemarlen 3 years ago
- :beetle: Fix query params for dataset table. NOTE: Use of v-skeleton-loader. If you don't do this the v-data-table-server component will reset the page value on load. See https://github.com/vuetifyjs... — committed to icefoganalytics/internal-data-portal by klondikemarlen 3 years ago
- :beetle: Fix flicker on datasets table. Solution: ignore page change while loading. This is a better fix for: > Use of v-skeleton-loader. If you don't do this the v-data-table-server component will r... — committed to icefoganalytics/internal-data-portal by klondikemarlen 3 years ago
- :art: Fix flicker on users table. Solution: ignore page change while loading. This is a better work-around for: > Use of v-skeleton-loader. If you don't do this the v-data-table-server component will... — committed to icefoganalytics/internal-data-portal by klondikemarlen 3 years ago
- fix(VDataTable): check for old search value type of undefined * fixed #17966 — committed to webdevnerdstuff/vuetify by webdevnerdstuff 3 years ago
- fix(VDataTable): avoid changing page if oldOptions not defined (#19542) fixes #17966 Co-authored-by: John Leider <john@vuetifyjs.com> — committed to vuetifyjs/vuetify by webdevnerdstuff 3 years ago
- fix(VDataTable): remove page clamp on initial render fixes #17966 closes #20185 — committed to vuetifyjs/vuetify by KaelWD 2 years ago
we need to fix it to implement this ability. Any help and PR are welcome
Is this just a bug in https://github.com/vuetifyjs/vuetify/blob/a95aeb2ce257bf08f5e0b4a132b9a0641cd0dcf9/packages/vuetify/src/components/VDataTable/composables/paginate.ts#L84?
Should it be something like
page.value = page.value || 1?I can confirm that this is a bug and it’s present at least from August this year. The workaround with the
items-lengthprop not only doesn’t fix anything, but completely messes up the pagination behaviorIt practically makes using the table pagination in sync with url parameters impossible.
+1 on this.
I cant initialise a table on any page other than 1.
Workaround: Don’t render the table until you have loaded the data. Use a skeleton load while you wait.
I can offer a temporary and very strange but working solution. If you add to your table
@update:page="() => {}"then everything starts working correctlyplayground
Yes I can confirm. Issue persist and datatable reset it always to 1 on mounting. I think this is easy fix
Still having this issue on
3.7.3The only reliable way I’m able to avoid this bug seems to be setting a default of
nullinstead of a number value.I believe this works because when items length is
nullno comparison to the page number can be made, so the page number’s value remains intact until items length is populated.I’ve implemented a solution where an initializing value is used to bypass the first @update:options=“updateOptions” event. This prevents unintended modifications during the initial table setup.
I really appreciate your work but i have to say I really don’t understand how this is labeled as maybe. How are we supposed to save the pagination in the navigation if the table keeps resetting to the first page?
vuetify 3.4.9 and still not fixed 😒 btw U can bring back options prop to VDataTable. Now with only update:options event is confusing, especially when U migrate from vue 2
Set the initial value of
items-lengthprop tox * items-per-pagewherexis the page you want to start on.I’m not sure if we should call this a bug or not. Maaybe we’d want different behavior in -server variant. I’ll keep this open for now.