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',
        ),
    ),
)); ?>
有帮助吗?

解决方案

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,
        ));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top