CGridView Paging with Filter - GET data error


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.



Hi gavin,

did you eventually figure out what caused this? I have the same problem, and really no clue what could cause it.

Hi Gavin & Narretz.

I’ve just tried on a working webapp:

  • I have 8 columns in my CGridView

  • Two of them have dropdown filters, the others text fields

  • I have 27 records

  • I filter a column with one of the dropdowns, it gives me 22 records

  • I go page 2

  • I try the filter again and it works

  • I even try the other dropdown to mix the two filters, and it works

Do you have a different use case to reproduce the behavior you’re talking about?

PS We’re talking filters in the grid, right?

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:


And so on.

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:




Note the many extra slashes and apparently all query parameters are repeated?