Some summaries of pagination in Yii2.0--yii\grid\gridview

Source: Internet
Author: User
Tags yii

Toss the afternoon, oh no, is fast one day, all six o'clock, first write a summary, then go to dinner, or will come back to forget the lazy wrote.

One, about the GridView page, search for Yiichina and Yiiframework, and Baidu, did not find their desired results, may be not found it, or really haven't encountered this problem.

First of all, I want to change the bottom part of the page component style, normal is to need its class, and then write style, match, show success. However, the reality is that I used some UI framework, set its paging component class name is "Am-pagination", its style class can not be said to be fixed, but it is also troublesome, because of various associations, and debugging CSS is a trouble and the generation of volunteers. So, keep the life of the class that is in the UI frame about the paging component unchanged, and modify the paging class name "Am-pagination" in the GridView to make it the same as the page-name of the UI's paging class.

How to modify it, said earlier, did not find their desired result is, did not find how to modify, and some are also about the use of the yii1.1.x of the GridView method. Directly paste the code of the GridView in the view, see note:


As shown above, about the paging component settings are mainly in the pager inside, the paging component is mainly related to the Yii\widgets\linkpager class, pager parameters are used to set the properties in Linkpager, and then call the render display. It took me so long to get this done, and I had two points of insight:

1. English or to study hard, do not want to read, you can also force yourself to see the English version of the reference, such as the content of Yiiframework, the original juice and nutrition ah.

2. Some things or the first good study theory, then to practice better, otherwise without the guidance of the theory, the practice of the road is always so tortuous bumpy.

Forget to say, the above page there is a place, the controller side, the normal only need to set the pagesize OK:

Second, some of the columns of customization, such as the last column--actioncolumn column, but also from the need for customization. I'm going to change the three view,update,delete icons I brought with them to the style of buttons. As shown in figure:


I do not know if this can be the same as the above pagination, in the view page through a similar template parameter modification, I have not tried, there will be a small partner can be a share of replies. My approach is to directly customize a new Actioncolumn class, inherit it, rewrite the functions inside the class, part of the code as follows:


Its parent, which is Actioncolumn, is doing the same for this function, as well as so much code. By the way, post some code for this function in Actioncolumn:


By comparing the above two graphs, you should be able to clearly set the Action column, which is the content style of the "Action" column.

Some Web sites are referenced during the resolution:

Http://www.yiichina.com/tutorial/92

Http://www.yiichina.com/tutorial/93

Comments and exchanges are welcome.

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.