gpage

package
v1.8.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package gpage provides useful paging functionality for web pages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page struct {
	Url            *url2.URL     // 当前页面的URL对象
	Router         *ghttp.Router // 当前页面的路由对象(与gf框架耦合,在静态分页下有效)
	UrlTemplate    string        // URL生成规则,内部可使用{.page}变量指定页码
	TotalSize      int           // 总共数据条数
	TotalPage      int           // 总页数
	CurrentPage    int           // 当前页码
	PageName       string        // 分页参数名称(GET参数)
	NextPageTag    string        // 下一页标签
	PrevPageTag    string        // 上一页标签
	FirstPageTag   string        // 首页标签
	LastPageTag    string        // 尾页标签
	PrevBar        string        // 上一分页条
	NextBar        string        // 下一分页条
	PageBarNum     int           // 控制分页条的数量
	AjaxActionName string        // AJAX方法名,当该属性有值时,表示使用AJAX分页
}

分页对象

func New

func New(TotalSize, perPage int, CurrentPage interface{}, url string, router ...*ghttp.Router) *Page

创建一个分页对象,输入参数分别为: 总数量、每页数量、当前页码、当前的URL(URI+QUERY)、(可选)路由规则(例如: /user/list/:page、/order/list/*page、/order/list/{page}.html)

func (*Page) EnableAjax

func (page *Page) EnableAjax(actionName string)

启用AJAX分页

func (*Page) FirstPage

func (page *Page) FirstPage(styles ...string) string

* * 获取显示“首页”的代码 * * @return string

func (*Page) GetContent

func (page *Page) GetContent(mode int) string

预定义的分页显示风格内容

func (page *Page) GetLink(url, text, title, style string) string

获取链接地址

func (*Page) GetUrl

func (page *Page) GetUrl(pageNo int) string

为指定的页面返回地址值

func (*Page) LastPage

func (page *Page) LastPage(styles ...string) string

获取显示“尾页”的内容

func (*Page) NextPage

func (page *Page) NextPage(styles ...string) string

获取显示"下一页"的内容.

func (*Page) PageBar

func (page *Page) PageBar(styles ...string) string

获得分页条列表内容

func (*Page) PrevPage

func (page *Page) PrevPage(styles ...string) string

/ 获取显示“上一页”的内容

func (*Page) SelectBar

func (page *Page) SelectBar() string

获取基于select标签的显示跳转按钮的代码

func (*Page) SetUrlTemplate

func (page *Page) SetUrlTemplate(template string)

设置URL生成规则模板,模板中可使用{.page}变量指定页码位置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL