【问题标题】:Modifiy Pagination style of clistview in yii修改yii中listview的分页样式
【发布时间】:2015-01-06 09:35:00
【问题描述】:

如何更改 clistview 分页样式。

Clistview 默认给出 First Previous 1 2 3 4... Next Last.

但我只想要分页样式的上一个和最后一个按钮。

我应该为这个改变做些什么?

【问题讨论】:

    标签: yii pagination clistview


    【解决方案1】:

    首先我认为你应该阅读CListView的文档: 并查看这些属性:模板、寻呼机、pagerCssClass。 “template”属性将定义如何显示您的CListView,而“pager”、“pagerCssClass”将定义您的分页。 stackoverflow上也有答案。

    祝你好运!

    【讨论】:

      【解决方案2】:

      你必须修改yii框架的CLinkPager类的createPageButtons函数才能这样做,没有快捷方式或配置。您将需要创建一个新组件来覆盖,或者如果这是整个项目的通用要求,您可以使用此代码更改 `CLinkPager' 的 createPageButtons 函数。

      protected function createPageButtons()
          {
              if(($pageCount=$this->getPageCount())<=1)
                  return array();
      
              list($beginPage,$endPage)=$this->getPageRange();
              $currentPage=$this->getCurrentPage(false); // currentPage is calculated in getPageRange()
              $buttons=array();
      
              // first page
              $buttons[]=$this->createPageButton($this->firstPageLabel,0,$this->firstPageCssClass,$currentPage<=0,false);
      
              // prev page
              if(($page=$currentPage-1)<0)
                  $page=0;
              $buttons[]=$this->createPageButton($this->prevPageLabel,$page,$this->previousPageCssClass,$currentPage<=0,false);
      
              // next page
              if(($page=$currentPage+1)>=$pageCount-1)
                  $page=$pageCount-1;
              $buttons[]=$this->createPageButton($this->nextPageLabel,$page,$this->nextPageCssClass,$currentPage>=$pageCount-1,false);
      
              // last page
              $buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1,$this->lastPageCssClass,$currentPage>=$pageCount-1,false);
      
              return $buttons;
          }
      

      【讨论】:

        猜你喜欢
        • 2019-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多