pageSize & Number of pagination Links

i am new to YII. migrated from zend to yii.

i need to know how to change pageSize value i want to show 20 record instead of default 10. and i wana change ajax pagination links to 5 instead of 10 default.

any idea i tried with ‘pagination’=>array(‘pageSize’=> 20) but that not worked for me.


 $pages->setPageSize(Yii::app()->params['listPerPage']); 

this is default

so use


$pages->setPageSize(20);

to change number of buttons add this to array

‘maxButtonCount’=>5,

$pages is object of which class ??

why not overide CLinkPager and

public $maxButtonCount = 5;

and than in view ‘pager’ => ‘application.extensions.my_page’,

$pages is my object name… u can use like this…

or post ur code




public function actionIndex()

	{

		$dataProvider=new CActiveDataProvider('User');

		$this->render('index',array(

			'dataProvider'=>$dataProvider,

                         

                         

		));

                   

	}


this my index view

<?php 

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

    'dataProvider'=>$dataProvider,

    //'pager' => 'application.extensions.my_page', //this is working

    'maxButtonCount'=>5, //this is not working 

    

    'columns' =>array(

                             'user_name',

                             'user_email',

                             'user_password',

                             'user_country',

                               array(

                                     'name' =>'date_created',

                                     'value'=>'date_format(date_create($data->date_created), "Y-m-d H:i:s")',

                                     ),

                             

                         )

));


?>




CGridView::pager property can be used to customize any of public properties of the pager (by default it’s CLinkPager). So you code should look like:




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

	'dataProvider'=>$dataProvider,

	'pager'=>array(

		'maxButtonCount'=>5,

		'pageSize'=>10,

	),

	...



ok i think u r telling about only Clinkpager

try like this




public function actionIndex()

	{

		$dataProvider=new CActiveDataProvider('User',array('pagination'=>array(

                        'PageSize'=>20,));

		$this->render('index',array(

			'dataProvider'=>$dataProvider,

                         

                         

		));

                   

	}



Thanks a lot Rajith it exactly I was looking for!!!

hi friends you can also use

$criteria = new CDbCriteria;

        &#036;total = Post::model()-&gt;count();





        &#036;pages = new CPagination(&#036;total);


        &#036;pages-&gt;pageSize = 20;


        &#036;pages-&gt;applyLimit(&#036;criteria);





        &#036;posts = Post::model()-&gt;findAll(&#036;criteria);





    &#036;this-&gt;render('index', array(


            'posts' =&gt; &#036;posts,


            'pages' =&gt; &#036;pages,


        ));