Yii Framework Forum: Render Cgridview Pager Separately - Yii Framework Forum

Jump to content

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

Render Cgridview Pager Separately Rate Topic: ***** 1 Votes

#1 User is offline   hakd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 11-August 12

Posted 12 October 2012 - 04:26 PM

Is it possible to render CGridView pager separately. For example, there is special placeholder on webpage for pagers defined in layout and it is required to display pager only there for every view that uses this layout.

Thanks.
0

#2 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 27-December 10
  • Location:china

Posted 12 October 2012 - 07:42 PM

it is possible:
in layout first define the placeHolder :
//  someLayout :

   if(isset($this->clips['pager'])){
            echo $this->clips['pager'];
   }



now you should pass the pager clip to the layout file (some other action/view will ignore the pager clip ):
   // let 's say it is your admin.php :

  $gridView =   $this->widget('zii.widgets.grid.CGridView',array('templage'=>'{items}{summary}'..));

 // few people know $this->widget return a widget obj and seldom use that object 

    // now you should pass the pager to the layout file:

    $this->beginClip('pager');
       $gridView->renderPager();
    $this->endClip();



you'd better to see the CClipWidget class . and think about why i use clip to pass html section to layout file :lol:
2

#3 User is offline   softark 

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

Posted 12 October 2012 - 08:20 PM

Wow, nice. I didn't know that.
Thanks for the tip!
0

#4 User is offline   hakd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 11-August 12

Posted 13 October 2012 - 02:46 AM

View Postyiqing95, on 12 October 2012 - 07:42 PM, said:

it is possible:
in layout first define the placeHolder :
//  someLayout :

   if(isset($this->clips['pager'])){
            echo $this->clips['pager'];
   }



now you should pass the pager clip to the layout file (some other action/view will ignore the pager clip ):
   // let 's say it is your admin.php :

  $gridView =   $this->widget('zii.widgets.grid.CGridView',array('templage'=>'{items}{summary}'..));

 // few people know $this->widget return a widget obj and seldom use that object 

    // now you should pass the pager to the layout file:

    $this->beginClip('pager');
       $gridView->renderPager();
    $this->endClip();



you'd better to see the CClipWidget class . and think about why i use clip to pass html section to layout file :lol:


Thank you so much! It is really that behaviour I've searched for.
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