CActiveDataProvider pagination loses sort

Hi all,

I have a CGridView which I am passing a CActiveDataProvider object to that contains data returned from a database query. When I click a column header the table is sorted by that particular column, however when I click "Next" the pagination seems to lose the sorting order. Is there a way to maintain the sorting order while paging?


use following code in your controller

if (isset($_GET['pageSize'])) {

            Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);



Thanks for the reply by that does not seem to work. It appears ‘pageSize’ is never passed to my controller as a GET variable.

you are check tab console firebug??

Not Firebug but I am using xdebug and breaking into the controller code.

The page index is give by a variable ending in _page ; for a filter having ‘Devices’ as the model type, it is: [size=2]Devices_page=2 . The sort order would be set in Devices_sort= .[/size]



[size=2]Normally this functionnality works out of the box, the ‘setState’ suggestion is only needed when you want to remember the page that you were on the next page visit.[/size]