Yii Framework Forum: Cgridview First Page's Pagination - Yii Framework Forum

Jump to content

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

Cgridview First Page's Pagination Rate Topic: -----

#1 User is offline   wael 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 03-August 12

Posted 01 March 2013 - 05:40 AM

Hi,

I can't solve the following problem :

I'm using Cgridview to display a list of articles.
I've set the pageSize to 10 per page
It's working fine, but if I join this table with another, the first page only displays 5 items, and the other ones are displaying 10/page
Does anyone have the solution for this ?

Thank you !!

Here's my code :

$criteria=new CDbCriteria(array(
'condition'=>'is_deleted=0 AND is_valid=1'.$recherche,
'select'=>'t.*'
));
$criteria->together = TRUE;

// if i add this line, then i got the pagination problem :
$criteria->with = array(
'images'=>array('joinType'=>'INNER JOIN', 'on'=>'images.annonce_id = t.id'),
);

$dataProvider=new CActiveDataProvider('Annonce', array(
'pagination'=>array(
'pageSize'=>10,
),
'criteria'=>$criteria,
));
0

#2 User is offline   Rajith R 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 884
  • Joined: 20-April 11
  • Location:India

Posted 02 March 2013 - 12:19 AM


                $total = Students::model()->count($criteria);
		$pages = new CPagination($total);
                $pages->setPageSize(Yii::app()->params['listPerPage']); // Note !!
                $pages->applyLimit($criteria);  // the trick is here!
		$posts = Students::model()->findAll($criteria);
		
		 
		$this->render('manage',array('model'=>$model,
		'list'=>$posts,
		'pages' => $pages,
		'item_count'=>$total,
		'page_size'=>Yii::app()->params['listPerPage'],)) ; // Note !!
	


Rajith Ramachandran,
Wiwo inc.
| Mobile: 919995504508
0

#3 User is offline   jacmoe 

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

Posted 02 March 2013 - 01:04 PM

/* moved from Bug Discussions */
"Less noise - more signal"
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