Clistview Only Retuning 4 Results On First Page

Hello all,

I am having a problem with my clistview. It is only returning 4 results on the first page and 10 on all the rest.

If i set the value it increases on the first page however it doesn’t show the right number on the first page.

i.e. if i set it to 20 it shows 14 on the first page and 20 on all the rest. It also makes my queries go from 7 to 18.

If I add $critera->order = ‘…’, it works right but increases my queries from 7 to 13

Anyone know why it’s doing this and how i can fix it?

Current code:




<?php

	$current_user = Yii::app()->user->id;

	$criteria = new CDbCriteria();

	$criteria->together = TRUE;

	$criteria->with = array(

	'creator0', 'updater0', 'addonphotos');

	$criteria->condition = 't.status=:status';

	$criteria->params = array(':status' => 1);

        $criteria->order = 'create_date DESC';//If I don't have this portion it doesn't work 

	$dataProvider = new CActiveDataProvider(Addon::model(), array('criteria'=>$criteria, 

	

	));


	$this->widget('zii.widgets.CListView', array(

		'dataProvider'=>$dataProvider,

		'itemView'=>'_view',

		'id'=>'addonListView',

		'pager'=> array(

			'header' => '',

			'footer' => '',

			'firstPageLabel' => 'First Page',

			'prevPageLabel'  => 'Prev. Page',

			'nextPageLabel'  => 'Next Page',

			'lastPageLabel'  => 'Last Page',

		),

		'template'=>'{sorter}{items}{pager}',

		'emptyText'=>'We did not find any items with your search critera. Please try another search.',

		'sortableAttributes'=>array(

			'name',

			'price',

			'create_date',

			'update_date'

	    ),

	)); ?>



In your first code, why don’t you use CActiveDataProvider’s pageSize (for example, 20 rows per page) ?




        $dataProvider = new CActiveDataProvider('Addon', array('criteria'=>$criteria, 'pageSize' => 20));



Thanks for the reply however, that throws and error…

500 Error | Property "CActiveDataProvider.pageSize" is not defined.

I have to use this


$dataProvider->pagination->pageSize = 20;

but that doesn’t work unless this is here


 $criteria->order = 'create_date DESC';

other wise it only shows 14 results even though it is set to 20.


 $criteria->order = 'create_date DESC';

that increased my queries from 7 to 13


$dataProvider->pagination->pageSize = 20;

that increased from 13 to 23

it works right if both are there but it increased my queries by 16 which doesn’t work.