Clistview Pagination Doesn't Work In Ajax Mode [Solved]

Hi dear friends,

Description the problem with an example:

If there was several pages(1,2,3,4,5, . . . ) for first page change(for example 2) ajax pagination doesn’t work. but when once the page changed with post method, in next requests for changing page ajax pagination works very well. what is the reason?

action for making dataProvider:




	public function actionIndex()

	{

    	if(isset($_POST['searchItem']) && $_POST['searchItem']!==null)

        	Yii::app()->user->setState('searchItem',$_POST['searchItem']);

    	$title=Yii::app()->user->getState('searchItem');


    	if(isset($_POST['category']) && $_POST['category']!==null)

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

    	$category=Yii::app()->user->getState('category');


    	if(isset($_POST['subCategory']) && $_POST['subCategory']!==null)

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

    	$subCategory=Yii::app()->user->getState('subCategory');


    	$criteria = new CDbCriteria();

    	$criteria->condition="status=:Verified or status=:Active";

    	$criteria->params=array(':Verified'=>Advert::Verified,':Active'=>Advert::Active);

    	if(!empty($title)) $criteria->compare('title',$title,true);

    	if(!empty($category)) $criteria->compare('category_id',$category);

    	if(!empty($subCategory)) $criteria->compare('sub_category_id',$subCategory);


    	$sort = new CSort();

    	$sort->defaultOrder=array(

        	'leaf'=>CSort::SORT_DESC,

        	'type'=>CSort::SORT_ASC,

    	);

		

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

        	'criteria'=>$criteria,

        	'sort'=>$sort,

        	'pagination'=>array(

            	'pageSize'=>10,

        	),

    	));


    	if((empty($dataProvider->data)))

        	Yii::app()->user->setFlash('Warning', '<strong>'.Yii::t('application','Item not found!').'</strong>');


    	if(Yii::app()->request->isAjaxRequest)

        	$this->renderPartial('index',array('dataProvider'=>$dataProvider));

    	else

        	$this->render('index',array('dataProvider'=>$dataProvider));

	}



[b]view:

[/b]




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

			'id'=>'result',

			'dataProvider' => $dataProvider,

			'itemView' => '_ad',

			'summaryText'=>'',

			'emptyText'=>'',

			'pager'=>array(

				'header'=>'',

				'prevPageLabel'=>'<',

				'nextPageLabel'=>'>',

			),

		));

	?>



[b]

[/b]

http://www.yiiframework.com/forum/index.php/topic/25901-pagination-solution-simple-and-complex-ways/

check this link this may help you

I tried this way also but ajax pagination doesn’t work.

Note that search box be rendered in site/index(main lauout). with an ajax request CListView rendered from search/index. I think the reason of problem is being involved the two controllers.

Via following change in search/index in renderPartial on ajax requests solved.


$this->renderPartial('index',array('dataProvider'=>$dataProvider),false,true);