Yii view operation-custom paging implementation method, yii view custom Paging

Source: Internet
Author: User

Yii view operation-custom paging implementation method, yii view custom Paging

This article describes how to implement custom pages for Yii view operations. We will share this with you for your reference. The details are as follows:

1. The View File calls cgridview. The custom paging method is called during clistview.

<? Php $ this-> widget ('zii. widgets. grid. CGridView ', array ('id' => 'news-grid', 'dataprovider' => $ model-> search (), 'filter' => $ model, 'template' => '{items} {summary} {pager}', 'selectablerdones' => 2, 'pager' => 'zpager ', 'summarytext' => 'page number: {pages}/{page} page', 'columns '=> array ('class' => 'ccheckboxcolumn ', 'footer '=>' <button onclink = "deleteAll ()"> button </button> <button onclink = "refashAll ()"> button </button> ', 'footerhtmloptions '=> array ('colspan' => 5), 'selectablerdones' => 2,), 'id', array ('name' => 'title ', 'htmlopexception' => array ('width' => '000000'), 'value' => 'mb _ substr ($ data-> title, 20%, "UTF-8 ") ',), array ('name' => 'content', 'htmloptions' => array ('width' => '123 '), 'value' => 'mb _ substr (strip_tags ($ data-> content), "UTF-8") ',), array ('name' => 'type ', 'value' => 'news: model ()-> getNewsType ($ data-> type) ',), 'user ', array ('name' => 'status', 'value' => 'news: model ()-> getNewsStatus ($ data-> status )',), array ('class' => 'cbuttoncolumn', 'buttons' => array ('view' => array ('visable' => 'false '), // 'delete' => array ('click' => 'true '),),),),));

2. Copy Base-class paging files and make modifications to your paging Method

Copy framework/web/widgets/pagers/CListPager. php and change the name of the class to protected/components/zpager. php.

Framework/web/widgets/pagers/pager.css copy the corresponding style file to protected/components/css/pager.css

Modify the css loading directory of zpager. php

public static function registerCssFile($url=null){ if($url===null)  $url=CHtml::asset(Yii::getPathOfAlias('application.components.css.pager').'.css'); Yii::app()->getClientScript()->registerCssFile($url);}

3. By modifying the Css style file, you can also modify the program that generates the list to modify the category.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.