How to customize Yii CGridView Pager?

23,357

Solution 1

You can custumize via 'pager' CGridView properties. Example:

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'My-grid',
    'dataProvider'=>$dataProvider,
    'pager'=>array(
        'header'         => '',
        'firstPageLabel' => '<<',
        'prevPageLabel'  => '<img src="images/pagination/left.png">',
        'nextPageLabel'  => '<img src="images/pagination/right.png">',
        'lastPageLabel'  => '&gt;&gt;',
    ),
    'template'=>'{pager}{items}{pager}',
    'columns'=>$arrayColumns,
));

Solution 2

  1. http://www.yiiframework.com/doc/api/CBaseListView#pager-detail
  2. http://www.yiiframework.com/doc/api/CBaseListView#pagerCssClass-detail
  3. http://www.yiiframework.com/doc/api/CLinkPager
Share:
23,357

Related videos on Youtube

tq0fqeu
Author by

tq0fqeu

Updated on July 09, 2022

Comments

  • tq0fqeu
    tq0fqeu almost 2 years

    How to customize Yii CGridView Pager about its position, css, template?

  • Sam Dark
    Sam Dark almost 14 years
    If you want just to customize how it looks you can use yiiframework.com/doc/api/CLinkPager#cssFile-detail to apply your own styles. These properties are specified in the array yiiframework.com/doc/api/CBaseListView#pager-detail. So property name is key, property value is value. If you want to customize markup itself or generation login it's better to create your own component that extends CLinkPager or CBasePager and specify its class as value of "class" key of CBaseListView::pager property.
  • ThorSummoner
    ThorSummoner about 10 years
    Please post the link's answer in your answer in case that link ever dies.

Related