JohnnyQ
JohnnyQ

Reputation: 5119

How do you set the page size of TbExtendedGridView in YiiBooster module?

Is there an option in TbExtendedGridView widget where you can set the items to be shown in each page? I currently have this setting

$this->widget('bootstrap.widgets.TbExtendedGridView',array(
'id' => 'client-list',
'dataProvider'=>$model->search(),
'filter'=>$model,
'type' => array('striped', 'bordered', 'condensed'),
'template' => '{pager}{summary}{items}{pager}',
'pagerCssClass' => 'pagination',
'rowCssClass' => 'pagination',
'pager' => array(
    'header' => '',
    'hiddenPageCssClass' => 'disabled',
    'maxButtonCount' => 3,
    'cssFile' => false,
    // 'class' => 'pagination',
    'prevPageLabel' => '<i class="icon-chevron-left"></i>',
    'nextPageLabel' => '<i class="icon-chevron-right"></i>',
    'firstPageLabel' => 'First',
    'lastPageLabel' => 'Last',
    'htmlOptions'=>array('class'=>'your_css_class'),
),
'columns'=>$gridColumns,
'responsiveTable' => true,
'enablePagination' => true,
));

EDIT

Thanks to @ineersa for the answer. I've modified my model's search function from this:

public function search() {
    $criteria=new CDbCriteria;
    $criteria->compare('first_name',$this->first_name,true);
    $criteria->compare('last_name',$this->last_name,true);

    return new CActiveDataProvider($this, array(
    'criteria'=>$criteria,
    ));
}

to this:

public function search() {
    $criteria=new CDbCriteria;
    $criteria->compare('first_name',$this->first_name,true);
    $criteria->compare('last_name',$this->last_name,true);

    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
        'pagination'=>array('pageSize'=>20),
    ));
}

Upvotes: 2

Views: 1136

Answers (1)

ineersa
ineersa

Reputation: 3435

I don't know about TbExtendedGridView, but i believe simple pagesize will do the job. Add this to your $model->search() before return:

$dataProvider->setPagination(array('pageSize' => 10));

Upvotes: 3

Related Questions