I’ve got the following use case for prev/next buttons, and I could not find an answer so maybe someone could give me some input on how to implement this best:
I have a index page with a gridview. The gridview is populated by an active data provider giving me a bunch of models. The user can filter and sort those models. Now I want the user to be able to go to a model view and look at the details. On this page there should be a next / prev button to reach the other models directly without the need to go back to the gridview.
How do I implement this? Should I serialize the activedataprovider and carry it to the view? Or should I should I just carry around a list of ids for the relevant models from the gridview?
Carrying around a large amount of data may be problematic, I guess.
I think all that you need is the searching/filtering parameters and the sorting order that were used in the index page. I would store them in the user’s session data, and use it in the individual item page to retrieve the next and the previous item.
Just an idea - maybe it can work simply like this:
Use a DataProvider together with ListView.
Set the paginator 'pageSize" of the DataProvider to 1. (1 item per page)
Let the ListView render a specific view for your item.
Modify the paginator template, to only show the PREV/NEXT buttons.
For my understanding that should actually work.
Thanks for the tips. I solved it like this now: In my index view, clone the DataProvider and set the pagination to off. Then get the list of keys from that dataprovider. Save that list in the session and read it in the detail view. Render prev/next buttons from that list.