GridView sorting + paging

Hi all,

I have a CGridView on my webpage connected to an CAjaxLinkPager to do the pagination. Data come from an CArrayDataProvider.

Here’s the code below:


	$columns = ... ; // column definitions are here


	$dataProvider = new CArrayDataProvider($data);


	$dataProvider->pagination = array(

		'pagesize' => 5,

		'route' => 'teamStuff/AjaxDeveloperList',

		'params' => $params,


	$dataProvider->sort = array(

		'attributes' => 

			array('developer' => array(

				'asc' => 'developerName',

				'desc' => 'developerName DESC'



		'defaultOrder' => 'id DESC',

		'route' => 'teamStuff/AjaxDeveloperList',



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

		'dataProvider' => $dataProvider,    	

		'pager' => array(


			'updateId' => 'membersListDiv',

			'loadingCssClass' => 'grid-view-loading',


		'id' => 'membersList',




I can sort the list by clicking on the header of the developer’s name column. That’s okay. If I want to go to the next page the sort setting will be lost.

How should I set up CGridView properly to be able to sort and do pagination the same time using AJAX?

Thank you in advance!

You can check this post here:

Thank you, but this is irrelevant to my question.

I was asking how could I make the CGridView sorting and pagination work together in an AJAX environment.


hi atis,

have you try

‘enablePagination’=>true, ?

or have you been solve this problem?