-
Notifications
You must be signed in to change notification settings - Fork 824
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
Persist GridField state between requests #3229
Comments
AFAIK State has some session backing. See |
Partly related: #3542 |
Putting everything into get variables is the "cleanest" when it comes to supporting multiple browser tabs, etc, although the get variable namespace can get cluttered and you can sometimes hit max-url-length issues. Perhaps immutable GridState can be stored in the session, so that you have a The session storage of that GridState would get cluttered, so maybe we would need some kind of garbage collection facility: a session could store a maximum of 100 GridStates, and the least recently accessed ones would be deleted. Alternatively, GridState could be packed into a JSON blob and saved as a single get variable. That would minimise namespace pollution, but might hit URL-length issues. For smaller quantities of GridState, it might be okay. Regardless, the number of different potential solutions here suggests that it would be good for GridField state management to be pluggable. |
I think that Immutable GridState + Garbage Collector should be the right way to handle this issue. |
Any news? It's a quite annoying issue when managing big GridField. |
I've just posted a $50 bounty for this: https://www.bountysource.com/issues/2778676-persist-gridfield-state-between-requests I've recently launched a site that has a booking system on it, a ModelAdmin displays 1 record per date for the next 2 years, allowing the admin to change the availability status for each date. With over 700 records, it's very annoying that when clicking Save & Close or Back from an EditForm, that it drops you back at the top of page 1 of the GridField. Can I just add, that as well as remembering which page you were on, it should also remember the position on that page, or at least scroll down the page to the position of the record that was just edited. For some things I find it's better to scroll down a long page of records than have to paginate through multiple pages. |
Tried getting some useful statelogic in gridviews with a JS only approach. See:
Perhaps this approach might work for you? |
The problem is that gridstate can be massive, with multiple potential keys per row. You would also need to solve the problem of having these querystring args on the top level page, not simply on gridfield postback handlers, as is current. |
I have a client who noticed this problem. In the end I added the following JavaScript to the CMS to add the query string to the form action:
For me this fixes it that when save is pressed the back, previous and next buttons all still contain the previous filter. Hopefully this is useful. |
Note that the "current page" state of GridFields in |
@steve-silverstripe has created another fix for this with https://github.com/littlegiant/silverstripe-persistentgridfield as well. |
Solved by silverstripe/silverstripe-admin#1314 |
As far as I can see right now everything for the GridField is handled via POST requests which means that whatever you've done with the GridField (paginated, sorted, searched etc) is lost if the page is reloaded.
A pretty common usecase where this becomes really annoying is when you have to do some kind of repetetive task with a number of records. Right now you search/filter/paginate for them, click one, edit & save. When that's done and you press back the GridField is reset and you have to do the search/filter/paginate thing all over again.
If this is accepted as an issue I'd be willing to tackle it with the caveat that I've no idea how to do this properly in the current context. Can we switch to get variables for search/filter/paginate? Should we store it in session (feels bad)?
The text was updated successfully, but these errors were encountered: