Cgridview Without Pagination And Record Limit

I have a CGridView with some data to display in it. I want to disable pagination and limit number of rows that can be displayed. I use the code:

'enablePagination' => false

and it did a half of the job: the paginator is gone, but the problem is that the grid shows now in summary that total number of records is equal to the page size. That’s not true. I need that total number of records to be reported correctly.

For example, if pageSize is 5 and there exist 7 records, CGridView reports "Displaying 1-5 of 7 results." when pagination is enabled, but it shows "Total 5 results." when pagination is disabled. I played with summaryText template, but it seems that {count} is incorrect when pagination is disabled.

In other words, is there a way to always have the summary "Displaying 1-5 of 7 results." irrespective to the fact if pagination is enabled?

you have to do this in dataprovider

$data= new CActiveDataProvider($model, array(




$data= new CActiveDataProvider($model);


Hi I am not sure if this what you looking for, it shows five records and shows 100000 records in summary

$dataProvider=new CActiveDataProvider('Model', array(

      'pagination' => array('pageSize' => 5),



This does not solve the problem. When I disable pagination in the data provider, I lost a possibility to limit number of records on a page via pageSize, and I see all records listed.

Moreover, this data provider is used by several pages, and I need to disable pagination only in one of them.

Yes, this is not what I’m looking for. This will preserve pagination, while I need to suppress it, totalItemCount should be automatically assigned from DB as it was with enabled pagination.

Currently I hide incorrect summary via summaryCssClass as a workaround.

Dear Friend

I do not have any option other than overiding the CGridView.




class GridView extends CGridView


public function renderSummary()





	echo '<div class="'.$this->summaryCssClass.'">';













		$summaryText=Yii::t('zii','Displaying {start}-{end} of 1 result.|Displaying {start}-{end} of {count} results.',$total);

		echo strtr($summaryText,array(











		$summaryText=Yii::t('zii','Total 1 result.|Total {count} results.',$count);

		echo strtr($summaryText,array(






			'{totalCount}'=>$this->dataProvider->getTotalItemCount(),//this is the added line.



		echo '</div>';





The widget.

<?php $this->widget('GridView', array( //GridView 





	'summaryText'=>'{count} out of {totalCount} items', //declare our new totalCount...



The dataprovider.

return new CActiveDataProvider($this, array(