A
A
Anton89892020-05-15 13:54:49
Vue.js
Anton8989, 2020-05-15 13:54:49

How to keep sort values ​​when moving to another page?

Good day) I have such a task, there are tables (like this vuetify), I
5ebe74ee62a25417467863.png
sort it, for example, by the Carbs field, then go to another page, and I want the sorting to remain the same, and so it would be possible to save sorting by all fields ( I decided to implement it through localStorage ), something doesn’t work out yet, could anyone help, thanks in advance))

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dima Polos, 2020-05-15
@Anton8989

If there is a page reload during the transition, then in the component that renders everything, it is necessary to read the data from localstorage in the created hook and pass the data to data, for example, to further render the DOM according to the settings from localStorage.
If without reloading, then you can store the data in the store, and work with the beforeEnter router hook, which will work before switching to the route, and at this moment you can get the settings data on how to render the component template.

B
bubaley, 2020-05-15
@bubaley

Hello, better use a store in which you store the sort state.

D
drawnofmymind, 2020-05-15
@drawnofmymind

And try mb keep-alive?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question