Save GridView state when edit button is clicked and go back

First of all, let me explain the scenario:

I have a template GridView

in a template and it works great. Now imagine the user has done the following:

  • He applied some filters to the data
  • It sorted by some columns too

What I want to do is preserve the value of his actions, i.e. save column sort values ​​and filter values ​​when he clicks on "edit → save" and goes back.

This is something similar to flash, but attributes. Is it possible to do this with built-in Yii2 tools?

+3


source to share


1 answer


Well, after assigning the parameters to your search model and before you return the data provider, you can simply save the search model in the session and then load it again when the user returns to the grid view.



In one application, I even use this method to store filters in user preferences rather than session so that they persist between sessions i.e. after the user logs out and back.

+2


source







All Articles