Question

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',
        ),
    ),
)); ?>
Was it helpful?

Solution

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,
        ));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top