问题
I am trying to set the pageSize property of pager in CGridView but in vain. By the way currently there are total of 2 items, i want to display only 1 on 1 page. Thanks.
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'pager' => array(
'pageSize' => 1,
),
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'username',
'email',
'pass',
'type',
'date_entered',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
回答1:
remove the following from the view
'pager' => array(
'pageSize' => 1,
),
inside the dataprovider array in your model search method add this code
$dataProvider = new CActiveDataProvider('your_model', array(
'pagination'=>array(
'pageSize'=>your_page_size,
),
'criteria'=>$criteria,
));
来源:https://stackoverflow.com/questions/18847385/unable-to-set-pagesize-for-pager-in-cgridview-yii