Bhavin Solanki Bhavin Solanki - 4 months ago 8
PHP Question

Display summary of cgrid view at bottom of grid

I use CGridView in Yii to create tables. I would like to show my table with pagination, but display summary text (i.e.

Displaying 1-4 of 4 results.
) at the bottom of grid. Is it possible in Yii?

Answer

You need to add this property to your array options widget:

'template'=>'{items}{summary}{pager}'

This is how it should look like:

$this->widget('zii.widgets.grid.CGridView', array(
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'enablePagination' => true,
        'template'=>'{items}{summary}{pager}',
        'columns'=>array(...)
        ),
    )); 

Yii docs - CBaseListView