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:


<?php

	$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(

			'class'=>'CAjaxLinkPager',

			'updateId' => 'membersListDiv',

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

		),

		'id' => 'membersList',

		'columns'=>$columns,

	));

?>

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:

http://www.yiiframework.com/forum/index.php/topic/21523-yii-reverse-cgridview-display-order/

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.

Up.

hi atis,

have you try

‘enablePagination’=>true, ?

or have you been solve this problem?