Is there an easy way to remember the grid filter settings, so when the user comes back the same filters are shown?
I would use session for this.
The grid uses a search model for the filtering:
http://www.yiiframework.com/doc-2.0/guide-output-data-widgets.html#filtering-data
As long as you can persist that in some way, you should be fine.
I am not sure if I am on the right track…
-
I store the value of the $param in the controller/search in a session
-
In the update I need to redirect back to the index
2a) In the update I retrieve the value from the session
2b) I call : return $this->redirect([‘index’]);
The thing I am struggeling with now is how to pass the search variables to the url
The index url is something like
OrganpartSearch%5Bname%5D=ff&OrganpartSearch%5Balt_name_csv%5D=&
This is urlencoded of
OrganpartSearch[name]=ff&OrganpartSearch[alt_name_csv]=&O
But how do I turn a php array to this format for passing into the
return $this->redirect([‘index’, -->values here<—]);
hmmm interesting… as soon as one formulates the question the answer comes to mind…
http_build_query($param)
However, now the redirect still does not work
return $this->redirect(['index',http_build_query($param) ]);
it turns the url into something like
npart/index?1=OrganpartSearch%255Bname%255D
instead of
index/?OrganpartSearch%5Bname%5D=dd&OrganpartSearch%5Bal
I just found another solution
In the actionIndex I store the used url (including parameters)
Url::remember(’’,‘namex’)
in the redirect I call
redirect(Url:previous(‘namex’) );
it seems to work very nice…
aNd so much simpler…