October 05 2013

Yii cgridview show first and last page in pagination

Tagged Under :

Yii
Default Yii cgridview pagination didn’t show the first and last page. But actually it was hidden but the CSS class, the easy method is change the CSS class to let it can show it.



how to do it? open pager.css file and find the code like below.

Controller error handler:
ul.yiiPager .first, ul.yiiPager .last {
    display: none;
}
Update display to inline, like below example
ul.yiiPager .first, ul.yiiPager .last {
    display: inline;
}
Now refresh your page. and you can see first and last page link at there.

Because the pager.css file at assets folder and it was generate by Yii. When the Application move to another machine or server the file will become invalid.

The solution is at the widget setting add the pager classes cssFile and path.
$this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider' => $dataProvider,
	'pager' => array(
		'cssFile' => '/yii/test/css/pager.css',
    ),
More properties you can refer here: http://www.yiiframework.com/doc/api/1.1/CLinkPager

Make a Comment

You must be logged in to post a comment.