A convenient drop down to select page size and save in User state.
Step 1: On top of my controller action for the gridview (if you used CRUD, this isactionAdmin() ) i added:
2
if
(isset(
$_GET
[
'pageSize'
])) {
3
Yii::app()->user->setState(
'pageSize'
,(int)
$_GET
[
'pageSize'
]);
4
unset(
$_GET
[
'pageSize'
]);
Step2: In the model (e.g. model/User.php ) the data provider in search() is configured like:
1
return
new
CActiveDataProvider(get_class(
$this
),
array
(
3
'pageSize'
=> Yii::app()->user->getState(
'pageSize'
,Yii::app()->params[
'defaultPageSize'
]),
Step 3: Now the view (e.g. views/user/admin.php ) :
03
$pageSize
=Yii::app()->user->getState(
'pageSize'
,Yii::app()->params[
'defaultPageSize'
]); ?>
10
'class'
=>
'CButtonColumn'
,
11
'header'
=>CHtml::dropDownList(
'pageSize'
,
$pageSize
,
array
(20=>20,50=>50,100=>100),
array
(
13
'onchange'
=>
"$.fn.yiiGridView.update('user-grid',{ data:{pageSize: $(this).val() }})"
,
Step 4: And finally the application parameter
http://www.yiiframework.com/forum/index.php?/topic/8994-dropdown-for-pagesize-in-cgridview/