CGridView: Simultaneously Filtering and Sorting

Hi All,

I recently upgraded my Yii code base to 1.1.5 and am now taking advantage of the awesome filtering capabilities of the CGridView component. I even have it filtering and sorting with a CGridView that is using a DataProvider containing my primary model and related model fields. All seems well, except that I just noticed that for some reason if I sort one of my columns (by clicking the column header) then filtering capabilities no longer work. Sorting by itself works, and filtering by itself works (e.g. if I haven’t sorted anything then I can filter on one or more fields), and sorting of filtered data even works. As soon as I sort a column, however, any additional filter data that I enter is just ignored. In fact, if I already have a field filtered, then apply a sort, the original filter continues to function. If I try to add a new filter condition, or even remove the original filter condition, the original value stays in place and the new value (if I had entered one) just disappears. Any thoughts or ideas as to why this would happen? I’m more than happy to provide code if it would help. Thanks in advance for any help!

The problem can be fixed by adding the following rule in urlRules:


If it is in a module you need to add this rule instead:


That did the trick! Thanks very much, GSTAR.

Thank two of you, GSTAR and Iuoshiben !!

I just have had exactly the same issue, and the solution above has solved it.