Cgridview Pager

anyone can help me, this is my code :

		$model = new CActiveDataProvider('GlVoucher',array(

			'criteria' => array(

				'condition' => "

					voucher_date >= '".Yii::app()->session['periode_from']."'

					and voucher_date <= '".Yii::app()->session['periode_to']."'",


				'select' => 'distinct voucher_no,voucher_date,voucher_remarks as remarks',

				'order' => 'voucher_no,voucher_date asc',





                'defaultOrder' => 'voucher_date ASC',




this work for me, but for count of page is not ‘distinct’ first.

the result is have a blank page at the end.

it’s strange… how can it display 276 results but there is only 154 records.

[color="#006400"]/* Moved from Bug reports (seriously??) to General Discussion … */[/color]

this problems is same with my problems now. can yo solve it?

Try instead:

	'select' => 'voucher_no,voucher_date,voucher_remarks as remarks',

	'distinct' => true,

CActiveDataProvider uses CActiveRecord::count() to calculate the total item count. And it eventually uses CDbCommandBuilder::createCountCommand() function.

It assumes that you set ‘distinct’ with ‘distinct’ property of the criteria, not in the ‘select’ property. (Use ‘Show’ link to view the source code.)