May 13 2013

Yii CGridView listdata with CArrayDataProvider and Pagination

Tagged Under :

Following last post CGridview listdata with CArrayDataProvider to list down the data with cgridview.

But it just can listing the records without the pagination. Use back last post example script and then modify the CArrayDataProvider as below example.

CArrayDataProvider Example:
$dataProvider = new CArrayDataProvider(
	array('keyField' => 'id',
		'totalItemCount' => 8,
			'pageSize' => 5
totalItemCount is total array Data. or you can using count($data) to get the total records
‘pageSize’ => 5 display how many records per page.

After that, try refresh the page. and you will able see the different.

Make a Comment