Pagination Required To Sort

Scenario… I do a search I get the results 5 per page. I have a field to sort by and it is by date. If I click to sort by date after I search it clears the page. If I click page 2 I can now sort by date go back to page 1 still works. Only on first load of the results does it not work correctly.

I look in the url in the status before I click sort by date and it is minimal at best only sort in the GET, if I change the page there are many variables being passed in GET. Now if I hover back over sort by date it is now populated with all the data from the search form.

How can I pass this data before having to call the AJAX from the pagination of the CGridView?

solution from this link


public function actionAdmin()


                $model=new PatientsFlags('search');

                $model->unsetAttributes();  // clear any default values









$model = new patientsFlags;


$dataProvider=new CActiveDataProvider('patientsFlags', array(

    'criteria'=>$model->search(), //hack to get ajax pagination to work






<?php $this->widget('zii.widgets.grid.CGridView', array(





        'cssFile' => Yii::app()->baseUrl . '/css/_styles.css',












I’m not seeing what you are saying… Pagination works just fine, it is the sort columns that isn’t until I change the page using the pagination.

I got it the solution was passing the form POST to the sort object.

$dataProvider->getSort()->params = $postData; // From $_POST in action

I had to do the same thing with pagination to work properly with my form. Except instead of getSort it was getPagination.

Thanks anyways for your assistance.