GF Frame Paging Module (i)-Basic introduction

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Article Source: http://gf.johng.cn/597431

Page management is implemented by the gpage package, Gpage provides powerful dynamic paging and static paging capabilities, and provides the developer with a high degree of flexibility in customizing the paging style.

How to use:

import "gitee.com/johng/gf/g/util/gpage"

Method List: Godoc.org/github.com/johng-cn/gf/g/util/gpage

func New(TotalSize, perPage int, CurrentPage interface{}, url string, route ...string) *Pagefunc (page *Page) EnableAjax(actionName string)func (page *Page) FirstPage(styles ...string) stringfunc (page *Page) GetContent(mode int) stringfunc (page *Page) GetLink(url, text, title, style string) stringfunc (page *Page) GetUrl(pageNo int) stringfunc (page *Page) LastPage(styles ...string) stringfunc (page *Page) NextPage(styles ...string) stringfunc (page *Page) PageBar(styles ...string) stringfunc (page *Page) PrevPage(styles ...string) stringfunc (page *Page) SelectBar() string

What we need to highlight here are three methods,, New GetContent , EnableAjax .

Create a Paging object

In the New method, the first three parameters are very simple, see the name of the known meaning.

The fourth parameter url string is the URL of the current request page, which can be a full URL address, such as: http://xxx.xxx.xxx/list?type=10#anchor or a URI absolute path address, such as: /list?type=10#anchor ; This parameter is the basis for the paging manager to calculate the paging URL address.

The fifth parameter route...string is an optional parameter that represents the route matching rule for the current request page (such as: /user/list/:page , or /order/list/*order-page ), which is required when static paging is used, so that the paging manager can intelligently replace the corresponding paging parameter in the static URI.

See the following sections for specific examples of use.

Predefined page-Pagination styles

Method GetContent provides a predefined, common paging style for quick use by developers. When a predefined style does not meet the developer's needs, developers can use public methods to customize the page style (or to implement a method overload for customization), or you can use regular substitution to specify portions of a predefined page style to implement customizations.

See the following sections for specific examples of use.

Using the Ajax paging feature

Method EnableAjax is given an Ajax method name for implementing Ajax paging, but it is important to note that the Ajax method name requires a uniform front-end convention, and that the Ajax method has only one URL parameter. The following is an example of a client-side definition of an Ajax method:

function DoAjax(url) {    // 这里读取URL的内容并根据业务逻辑进行内容展示}

See the following sections for specific examples of use.

Related Article

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.