CGridview + prefilled filters + pagination not working

I have a gridview where I prefill some of the filters; they are working correctly.

However, the pagination makes the predefined filters disappear:


Original dataset is 40 rows (20 with STORE ID 12, 20 with STOREID 13).

Gridview with 3 columns (STORE, CUSTOMER, ORDERNR), 2 pages with each 10 rows. This result is filtered by a predefined filter field (STORE: 12), so it shows all rows carrying STORE ID 12. When I use the filters on CUSTOMER OR ORDERNR, it works fine (results are filtered as expected. However, when I click on page 2, the filters are not remembered and the entire result set is displayed. When I do a filter on CUSTOMER or ORDERNR and remove this (so the resultset is 20 again, and THEN click on page 2, the filter for STORE is remembered correctly and carried through. The url link for the page also has no reference to the predefined filter at all.

So initial value:

Filter of STORE is set to 12

Filter of CUSTOMER is set to ‘’

Filter of ORDERNR is set to ‘’

Link of Page 2 is set to ?Orders_page=2

When setting filter of CUSTOMER to ‘name’ and then removing the filter, the link of page 2 is set to:


As you can see, the filter is initialized correctly in the latter case, but not in the initial case.

Is there something I’m missing? Or is there a trick to initialize the pagination links with the preset filters?

Right now I’m using a session variable to trick the grid into using the remembered filters, but it’d be easier if there was better way :)


where are you setting the predefined filters… .this should work if you set them in the controller after the $model = new YourModel;