【问题标题】:CgridView pagination linkCgridView 分页链接
【发布时间】:2011-12-05 22:59:03
【问题描述】:

在我的项目中,我使用 cgridview 来显示一些信息并使用使用 cgrid 视图构建的分页。但现在我面临分页的可用性问题。也就是说,考虑到我有 3 页,分页看起来像 >>。 当我点击第三页时,分页应该看起来像 ,如果是第一页,分页应该看起来像 1 2 3 > >>。我怎样才能做到这一点。请给我一个解决方案。

我的小部件看起来像。

$widget = $this->widget('zii.widgets.grid.CGridView', array(
                    'id' => 'request-grid',
                    'dataProvider' => $model->search(),
                    'cssFile' => Yii::app()->baseUrl . '/media/css/gridview.css',
                    'summaryText' => '',
                    'enablePagination' => true,
                    'template' => '{items}',
                    'pager' => array(
                        'class' => 'LinkPager',
                        'cssFile' => false,
                        'header' => false,
                        'firstPageLabel' => 'First',
                        'prevPageLabel' => 'Previous',
                        'nextPageLabel' => 'Next',
                        'lastPageLabel' => 'Last',
                    ),
                    'columns' => array(......));

我也在组件 LinkPager 中扩展 CLinkPager 类。

class LinkPager extends CLinkPager
{
    public $maxButtonCount=3;
}

【问题讨论】:

    标签: yii pagination cgridview


    【解决方案1】:

    在你的css文件中你需要写

    .yiiPager .hidden, .yiiPager .first, .yiiPager .last {
    display: none;
    }
    

    【讨论】:

    • 谢谢哥们。你是 Yii 专业 CGridView 的超级英雄...非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2011-12-14
    • 2013-08-20
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 1970-01-01
    • 2014-07-18
    • 2013-01-28
    相关资源
    最近更新 更多