Yii中CLinkPager结合Bootstrap的样式分页
2012-12-16 01:26
567 查看
Controller中:
组件Page,为了方便使用把样式的相关属性放到该组件中了。
最后是页面呈现部分:
主要说个问题,在CLinkPager有一段代码,就是自动加载Css文件的,因为Yii自己默认带了一套css,这里不想使用,那么要设置为false,也就是Page组件当中的cssFile属性。
最后的效果图:
public function actionIndex() { $dataProvider = new CActiveDataProvider('Admin', array( 'criteria' => array( 'order' => 'aid desc', ), //'pagination' => false, 'pagination' => array( 'pageSize'=> Page::SIZE, ), )); $this->render('index', array( 'data' => $dataProvider, )); }
组件Page,为了方便使用把样式的相关属性放到该组件中了。
class Page { const SIZE = 15; static function go($pages) { return array( 'header' => '', 'firstPageLabel' => '<<', 'lastPageLabel' => '>>', 'firstPageCssClass' => '', 'lastPageCssClass' => '', 'maxButtonCount' => 8, 'nextPageCssClass' => '', 'previousPageCssClass' => '', 'prevPageLabel' => '<', 'nextPageLabel' => '>', 'selectedPageCssClass' => 'active', 'pages' => $pages, 'internalPageCssClass' => '', 'hiddenPageCssClass' => 'disabled', 'cssFile' => false, 'htmlOptions' => array( 'class' => '' ), ); } }
最后是页面呈现部分:
<div class="span10"> <table class="table table-bordered"> <tr> <th><?php echo Yii::t('zh', 'admin.field.id');?></th> <th><?php echo Yii::t('zh', 'admin.field.name');?></th> <th><?php echo Yii::t('zh', 'admin.field.mail');?></th> <th><?php echo Yii::t('zh', 'admin.field.role');?></th> <th><?php echo Yii::t('zh', 'admin.field.ip');?></th> <th><?php echo Yii::t('zh', 'common.field.created');?></th> <th><?php echo Yii::t('zh', 'common.field.updated');?></th> </tr> <?php foreach ($data->getData() as $key => $value): ?> <tr> <td><?php echo $value->aid; ?></td> <td><?php echo $value->name; ?></td> <td><?php echo $value->mail; ?></td> <td><?php echo $value->role; ?></td> <td><?php echo $value->ip; ?></td> <td><?php echo $value->updated; ?></td> <td><?php echo $value->created; ?></td> </tr> <?php endforeach; ?> </table> <div class="pagination"> <?php $this->widget('CLinkPager', Page::go($data->getPagination())); ?> </div>
主要说个问题,在CLinkPager有一段代码,就是自动加载Css文件的,因为Yii自己默认带了一套css,这里不想使用,那么要设置为false,也就是Page组件当中的cssFile属性。
public function registerClientScript() { if($this->cssFile!==false) self::registerCssFile($this->cssFile); }
最后的效果图:
相关文章推荐
- yii中clinkpager结合bootstrap的样式分页
- yii使用bootstrap分页样式
- yii CLinkPager 分页控件
- yii CLinkPager 分页控件
- Thinkphp和Bootstrap结合打造个性的分页样式(推荐)
- yii使用bootstrap分页样式的实例
- 学习笔记之bootstrap+thinkphp分页样式
- jQuery写的一个分页展示的demo(结合bootstrap)
- datatables的Bootstrap样式的分页怎么添加首页和尾页(引)
- Yii框架结合sphinx,Ajax实现搜索分页功能示例
- Vue.js结合bootstrap实现的分页控件
- 简述bootstrap 之间版本的区别。以及结合springmvc 生成table 分页,传参
- bootstrap下拉列表与输入框组结合的样式调整
- web.py可用的分页代码,bootstrap 分页样式哦
- bootstrap下拉列表与输入框组结合的样式调整
- mvc 、bootstrap 结合分布式图简单实现分页
- Bootstrap—分页Pagination和翻页Pager
- 修改ASP.NET MVC Ajax分页组件ASP.NET MvcPager一个小Bug并修该样式为自己所用(三)