I am using a CGridView (very simple query ‘select * from courses’ ) with paging and filters at the bottom.
The filters work when I don’t use paging. And the paging works fine. However if I first filter the page and then use the paging (eg: go to the 2nd page) and then try to change the filter it doesn’t work.
Steps to simulate:
CGridview with enough records for paging to show and filter(s) (eg: list of people with a drop down filter for their gender).
Now filter using the drop down (there should be enough records so you can page).
Click on Page 2
Now filter the drop down again; the filter will reset to the previous filter.
I tried this on most of my pages and using the google web developer tools and noticed that the values in the ajax request are being sent properly (eg if my first filter was “Male” and after paging I’m filtering “Female”; the query string the corresponding value is “Female”). However, if I print the $_GET the corresponding value is of the previous filter(ie it shows as “Male”).
Please help me this is really urgent. Let me know if you would like me to post the code too. Thank you in Advance.
edit: Ok, I got it. Problem is when you use urls in path format, and have either a module or subfolders for your controllers the ajax url is wrongly created when filtering after you paged. you have to add an explicit url rule to handle these cases. So I just changed the url rules to:
Hi bennouna, yes I used the filters in the grid. In my case, it is a textfield, but the behavior is the same.
I could be because I search attributes of related models in the gridview; however, the problem occurs even when I search native model fields or when I remove all additional fields.
I noticed that it works mostly with the default implementation, i.e. what Gii generated, but now I have one admin action where it works, and one where it doesn’t.
Actually, at the moment I think it might be related to the number of results.
I got something: Seems like the url is wrongly serialized or something: Correct: