Where to set default pagesize?

Hi guys

I’m new here so be gentle ;)!

After using yii for quite some time i know it quite good already.

Directly to my question: Is there a way to set the default pagesize (eg for CGridView) in the main app config (/protected/config/main.php)!? If so…how would i do it?

I’m aware of that i can set the value in the model via a public param of the config like so:

public function search()


		// Warning: Please modify the following code to remove attributes that

		// should not be searched.

		$criteria=new CDbCriteria;







		return new CActiveDataProvider($this, array(







But I’m looking for a cleaner way to set this value globally in the config without having to touch each model. I found no such solution on the web or in this forum…

thanks already in advance,


http://www.yiiframework.com/doc/api/1.1/CPagination, CPagination is the class that controls CDataProvider instances with page size etc. The thing is, CGridView doesn’t actually control page sizes, that’s the CDataProvider’s job.

So here are some of your options:

  1. Edit CPagination (Yuck!)

  2. Extend CPagination and have your version pull the data out of config. Then set it as the pagination object for CActiveDataProvider with the setPagination() method. You could even extend CActiveDataProvider so it used your Pagination class as it’s default Pagination object.

  3. Keep doing it the way you are doing it now.

Hi Luke

Thanks a lot for your answer. Option 1 really is no option ;)! Hmm good idea…no clue why i thought about that after deriving a lot of other classes already :D!

Thanks a lot for your time!

"Yii => custom WidgetFactory, adds onBeforeCreateWidget, onAfterCreateWidget events. An example of how the custom class can be used has been provided as well, in the process solving a typical Yii issue, regarding how to set the default pagesize for widgets that use dataproviders (due to dataproviders initializing pagination, by which widget pager settings are typically ignored)."

hi friends you can set pagination by

$dataProvider = new CActiveDataProvider('model name',



					'pagination' => array('pageSize' => 50,),