Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI Basic Plugins - Pagination

jQuery EasyUI Basic Plugins - Pagination


jQuery EasyUI Plugins jQuery EasyUI Plugins


Override the default defaults through $.fn.pagination.defaults.

Pagination allows users to navigate data by turning pages. It supports configurable options for page navigation and page length selection. Users can add custom buttons on the right side of the pagination to enhance functionality.

Depends on

Usage

Create pagination through markup.



Create pagination using javascript.





$('#pp').pagination({

    total:2000,

    pageSize:10

});

Let's create ajax pagination using the panel and pagination plugins. When the user selects a new page, the panel will display the corresponding content of that page.



The top panel displays the content of the first page by default. When the user navigates pages, the 'onSelectPage' event will be triggered, which calls the 'refresh' method for the content panel to load the new page content with a new URL parameter.

property

Name Type Description Default value
total number The total number of records, which should be set when creating the pagination. 1
pageSize number The page size. (Note: the maximum number of records displayed per page) 10
pageNumber number The page number displayed when the pagination is created. 1
pageList array Whether the user can change the page size. The pageList property defines the available sizes.
 代码实例:     

$('#pp').pagination({     pageList: [10,20,50,100] }); | [10,20,30,50]| onSelect | event | loading | boolean | Defines whether data is loading. | false| onSelect | event | buttons | array,selector | Defines custom buttons. Possible values:
1) An array, where each button contains two properties:
iconCls: a CSS class that displays a background image
handler: the handler function called when the button is clicked.
2) A selector indicating the buttons.

 按钮可通过标记声明:     

Buttons can also be created using javascript:

$('#pp').pagination({

    total: 114,

    buttons: [{

        iconCls:'icon-add',

        handler:function(){alert('add')}

    },'-',{

        iconCls:'icon-save',

        handler:function(){alert('save')}

    }]

});

| null| onSelect | event | layout | array | Defines the pagination layout. This property is available since version 1.3.5.
Layout items include one or more of the following values:
1. list: the list of page sizes.
2. sep: the separator between page buttons.
3. first: the first button.
4) prev: the previous button.
5) next: the next button.
6) last: the last button.
7) efresh: the refresh button.
8) manual: a manual page-number input box for entering a page number.
9) links: page-number links.

 代码实例:     

$('#pp').pagination({     layout:['first','links','last'] });| onSelect | event| onSelect | event | links | number | The number of links; valid only when the 'links' item is included in 'layout'. This property is available since version 1.3.5. | 10| onSelect | event | showPageList | boolean | Defines whether to display the page list. | true| onSelect | event | showRefresh | boolean | Defines whether to display the refresh button. | true| onSelect | event | beforePageText | string | Display a label before the input component. | Page| onSelect | event | afterPageText | string | Display a label after the input component. | of {pages}| onSelect | event | displayMsg | string | Display a page information. | Display {from} to {to} of {total} page information. |

Events

Name Parameters Description
onSelectPage pageNumber, pageSize Fired when the user selects a new page. The callback function takes two parameters:
 pageNumber:新of页码       

 pageSize:新of页面尺寸       

   

 代码实例:     

$('#pp').pagination({     onSelectPage:function(pageNumber, pageSize){         $(this).pagination('loading');         alert('pageNumber:'+pageNumber+',pageSize:'+pageSize);         $(this).pagination('loaded');     } });| onSelect | event | onBeforeRefresh | pageNumber, pageSize | Fired before the refresh button is clicked; returning false cancels the refresh.| onSelect | event | onRefresh | pageNumber, pageSize | Fired after refreshing.| onSelect | event | onChangePageSize | pageSize | Fired when the user changes the page size. |

Method

Name Parameters Description
options none Return the options object.
loading none Put the pagination into the loading state.
loaded none Put the pagination into the loaded state.
refresh options Refresh and display the pagination information. This method is available since version 1.3.
 代码实例:     

$('#pp').pagination('refresh'); // refresh the pagination bar information $('#pp').pagination('refresh',{ // change the options and refresh the pagination bar information total: 114, pageNumber: 6 });| onSelect | event | select | page | Select a new page. The page index starts from 1. This method is available since version 1.3.
Code example:

$('#pp').pagination('select');    // 刷新当前页面

$('#pp').pagination('select', 2);    // 选择第二页

|


jQuery EasyUI Plugins jQuery EasyUI Plugins