-
Notifications
You must be signed in to change notification settings - Fork 509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting a paginated table #399
Comments
update1 : I changed the following :
The result is a huge loading time (~5 sec) between the call for sorting and the table being sorted... for only 44 items in my array. update 2 : I rewritten the sorting function without the orderBy function :
The sorting process is now a lightning speed for 44 items. The remaining problem is the function mutating the array, instead of just returning a sorted version of it. The good point for this method is the user can have full control about how the data is sorted. update 3 : the last update for now - I managed to plug things the right way (for me) :
The original array is never mutated, the sorting operation is fast and I can control how it's done, and when it's neither asc nor desc everything's back to normal. The last thing I'd like to improve is the x2 slicing process, as below the
I don't know if there's any side effect I missed so far. |
I understand the issue here. Would you mind opening a PR with your changes as it's quite hard to try with codeblocks here. |
is this what you are looking for? @benjamincanac |
Hello. I am still unable to get a paginated table to sort properly, even after this fix. Has anyone confirmed that #803 indeed fixes this specific problem? Here is the sample code I am trying:
The first item on the first page should be "Acer SB220Q bi 21.5 inches Full HD (1920 x 1080) IPS Ultra-Thin" but instead it is "Fjallraven - Foldsack No. 1 Backpack, Fits 15 Laptops". I am just starting out learning Vue and Nuxt, so it could totally be something I am doing wrong...due to my inexperience. |
Hello. You tried
apply your own sorting function or use `import { orderBy } from 'lodash-es' |
This feature is in the development version, it is not in version 2.9 |
Thanks for the suggestion. After thinking about this for a bit and reading some other posts regarding this, I came to the conclusion that sorting a paginated table might not make the most sense. Maybe on the first page, but then trying to sort on subsequent pages would have a "wierd" user experience. What I ended up doing is sorting the initial results from the useFetch so at least the "first view" of the table, on page one, was correctly sorted. Then after then...it only sorts per page which I think is what the end user would expect. This is basically what you describe in your post...I did a slightly different way but same results. Thanks again. |
Here is my solution : https://pastebin.com/MShRWrba |
The sorting of a paginated table by a column only applies to the currently displayed page. I know it's normal since we pass a composed, sliced value of the table, but it would be nice if there was an option to pass the original dataset to sort, or to easily setup a callback function that would perform the sort on the variable before slice ?
Version
@nuxthq/ui: 2.5.0
nuxt: 3.6.1
Reproduction Link
https://stackblitz.com/edit/nuxtlabs-ui-ncvb57?file=app.vue
What is Expected?
I'd like to sort the whole dataset before slicing for pagination, but the component applies the sort on the sliced dataset.
The text was updated successfully, but these errors were encountered: