Yii Framework Forum: Cgridview Pager - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cgridview Pager CGridView have problem at count of page (distinct query) Rate Topic: -----

#1 User is offline   nixnix 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 04-May 11

Posted 11 October 2012 - 02:31 AM

Posted Image

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',
			),
			'pagination'=>array(
	                'pageSize'=>10
	        ),
                '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.
0

#2 User is offline   nucreativa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 25-June 12

Posted 11 October 2012 - 03:12 AM

it's strange... how can it display 276 results but there is only 154 records.
0

#3 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 12 October 2012 - 01:36 PM

/* Moved from Bug reports (seriously??) to General Discussion .. */
"Less noise - more signal"
0

#4 User is offline   apinx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-March 12

Posted 06 January 2013 - 09:22 PM

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

#5 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,084
  • Joined: 16-February 11
  • Location:Japan

Posted 06 January 2013 - 10:22 PM

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.
http://www.yiiframew...tCommand-detail
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.)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users