Clistview With Pagination

I don’t get along with pagination for one of my CListView. In my controller I fetch records to a CActivedataProvider by using a criteria and I pass that data provider to my CListView. I can see that database fetch is working fine since I can see all records in my CListView if I don’t apply pagination.

The problem begins when pagination is turned on. I would like to see all records on a separate page with a pagination at the bottom.

What I’m doing wrong?

Thanks in advance,

Here is what I have in my controller:


if(isset($_POST['Lista']))

			{

				$model->attributes=$_POST['Lista'];

			}

			

			$egyedi_osszetevo_idk = Lista::getEgyediOsszetevoIdk($model->datum_tol, $model->datum_ig);

			

			$criteria = new CDbCriteria();

			$criteria->addInCondition("id", $egyedi_osszetevo_idk);

			$count = EtelOsszetevo::model()->count($criteria);

			

			$pages=new CPagination($count);

			$pages->pageSize=1;

			$pages->applyLimit($criteria);

			

			$dataProviderEgyediOsszetevok = new CActiveDataProvider('EtelOsszetevo', array(

							'criteria'=>$criteria,

							'pagination'=>$pages,

					));

			

			$this->render('view',array('model'=>$model,

			  			               'egyedi_osszetevo_idk'=>$dataProviderEgyediOsszetevok,

						               ));

Here is my CListView in my view file:


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

			'dataProvider'=>$egyedi_osszetevo_idk,

			'itemView'=>'_view',

));

maybe let the dataprovider setup the pagination?




$dataProviderEgyediOsszetevok = new CActiveDataProvider('EtelOsszetevo', array(

    'criteria'=>$criteria,

    'pagination' => array(

        'pageSize' => 1,

    ),

));

Hi,

It should be like this





return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

			'pagination'=>array(

				'pageSize'=>20,

			),				

			'sort'=>array(

				'defaultOrder'=>'pgm_credit DESC',

			),

		));



so my advice delete those lines :)

Still doesn’t work. When I click on next page button it loads my main menu into the view.

I’m not really getting this. So, you say that I need to use return instead of render? I have to pass another model to my view as well that’s why I use render.

Thanks,