YII中CListView列表形式的模板设置,包括pager和sorter的细节

其实在API中写得挺详细的,但我没记住,所以决定在此写下自己的方法,增强记忆。

CListView的API:http://www.yiiframework.com/doc/api/1.1/CListView

分页器CLinkPager的API:http://www.yiiframework.com/doc/api/1.1/CLinkPager

 

以下较全面的定义了所有可配置项:

$this->widget('zii.widgets.CListView', array(

    'dataProvider'=>$dataProvider,


    'itemView'=>'_view',


    'template'=>'<div class="summary">{summary}</div><div class="sorter">{sorter}</div><div class="list">{items}</div><div class="pager">{pager}</div>',

    //template是整个CListView的模板:

    //{summary}的位置会显示基本描述,可修改summaryText项来设置描述的模板

    //{sorter}的位置会显示更改排序方式的按钮,需要定义sortableAttributes项来描述哪一属性是可排序的

    //{items}的位置会显示列表,列表中每一项的格式来自itemView项定义的文件

    //{pager}的位置会显示分页器,可通过定义pager项来设定分页器的显示方式

 

    'summaryCssClass'=>'summary_container',//定义summary的div容器的class

    'summaryText'=>'共{count}条,当前页显示第{start}-{end}条',

    //定义summary的显示内容,其中可用到以下变量:

    //{start}表示本页的第一条是全部中的第几条

    //{end}表示本页最后一条是全部中的第几条

    //{count}表示全部共几条

    //{page}表示当前页码

    //{pages}表示总页数

 

    'sortableAttributes'=>array('title','create_time'),//定义可排序的属性

    'sorterCssClass'=>'sorter_container',//定义sorter的div容器的class

    'sorterHeader'=>'更改排序:',//定义的文字显示在sorter可排序属性的前面

    'sorterFooter'=>'',//定义的文字显示在sorter可排序属性的后面

 

    'pagerCssClass'=>'pager_container',//定义pager的div容器的class

    'pager'=>array(

        'class'=>'CLinkPager',//定义要调用的分页器类,默认是CLinkPager,需要完全自定义,还可以重写一个,参考我的另一篇博文:http://blog.sina.com.cn/s/blog_71d4414d0100yu6k.html
        'cssFile'=>false,//定义分页器的要调用的css文件,false为不调用,不调用则需要亲自己css文件里写这些样式
        'header'=>'转往分页:',//定义的文字将显示在pager的最前面

        'footer'->'',//定义的文字将显示在pager的最后面
        'firstPageLabel'=>'首页',//定义首页按钮的显示文字
        'lastPageLabel'=>'尾页',//定义末页按钮的显示文字
        'nextPageLabel'=>'下一页',//定义下一页按钮的显示文字
        'prevPageLabel'=>'前一页',//定义上一页按钮的显示文字

        //关于分页器这个array,具体还有很多属性,可参考CLinkPager的API
    ),
));

 

http://blog.sina.com.cn/s/blog_71d4414d01013lll.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
非常好用的CListCtrl加强版。 从CListCtrl继承,完全兼容CListCtrl. 它有以下特性: • The background of the sorted column can be displayed in a different color (like the detailed view of Windows XP Explorer). • The header of the sorted column can display an arrow that indicates the sort direction (like the detailed view of Windows XP Explorer). • You can give the user the opportunity to hide or redisplay selected columns by just clicking on the header control with the right mouse button (see picture below). • You can hide or redisplay a selected column entirely. • In contrast to the original list view control, the first column can have the LVCFMT_CENTER or LVCFMT_RIGHT style, too. For this feature, the list view control must have the LVS_OWNERDRAWFIXED style. • The label attributes state icon, small icon, and selection can always be shown in the leftmost column, independent of the order of the columns. For this feature, the listview control must have the LVS_OWNERDRAWFIXED style. • You can supply tooltips not only for the whole item, but also for the small icon, the state icon, and each subitem label. • The extended styles LVS_EX_CHECKBOXES, LVS_EX_ONECLICKACTIVATE, LVS_EX_SUBITEMIMAGES, LVS_EX_TWOCLICKACTIVATE, and LVS_EX_UNDERLINEHOT will be supported even if the list view control has the LVS_OWNERDRAWFIXED style. • If the LVS_EX_CHECKBOXES style has been applied and a selected item will be checked/unchecked, all other selected items will be checked/unchecked, too. • If the LVS_EX_LABELTIP style has been applied, not only the partially hidden text of the item label will be unfolded but also the partially hidden text of each subitem label. Note: The LVS_EX_LABELTIP style will be supported under all operating systems. • Tooltips and expanded labels can be displayed simultaneously. • The current state of the list view control (column widths, column order, hidden columns, and sort column and direction) can be saved and restored.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值