CListView forgets criteria after AJAX sort

Hi,

I have a weird problem.

I have a page with a CListView and a search form. When submitting the form, the controller creates a new CDbCriteria with the inputs from the form and re-displays the page, so that now the CListView contains only the items the user wanted.

So far so good.

The problem is that if I click the "sort by" link of the CListView, the CListView (or, more accurately, the CActiveDataProvider attached to it) "forgets" the criteria and shows the full list of data items, albeit sorted.

Any ideas?

Turns out that CListView, when using AJAX, renders the whole page from scratch. Of course, my search form was not submitted with it, therefore the criteria was not filtered.

The workaround I found was to save the form’s fields into a cookie, thus making them available when the action is called by AJAX.