Home Web Front-end JS Tutorial jquery easyui paging tutorial examples

jquery easyui paging tutorial examples

Jun 19, 2017 pm 03:15 PM
easyui jquery use Pagination Tutorial

In web development, we often encounter the need for paging. If we rely on hand-written code, there may be a lot of code and the style will not look good. Here is an introduction to jquery easyui Paging function, which is very convenient and simple

Then after including the necessary files according to the "jquery EasyUI Framework Usage Document", just insert the following code in $(function(){ });:

 $('#pp').pagination(options);
Copy after login

Let’s introduce Pagination For specific usage, first look at the attributes:

Attribute name type description default value

total number Set the total number of records when paging is established 1

pageSize number per page The number displayed 10

pageNumber Number When paging is established, the number of pages displayed 1

pageList array Users can modify the size of each page, the

pageList attribute defines how many The size can be changed. [10,20,30,50]

loading Boolean defines whether the data is loading false

buttons array defines custom buttons, each button contains two attributes:

iconCls: CSS class for displaying background image

handler: handler function when a button is clicked null

showPageList Boolean defines whether to display the page list true

showRefresh Boolean defines whether to display the refresh button true

beforePageText string in the label displayed before the input box groupPage

afterPageText string in The label of {pages}

displayMsg string displayed after the input box component displays the information of a page.

Displaying {from} to {to} of {total} items Event Event Name Parameter Description onSelectPage pageNumber, pageSize Triggered when the user selects a new page, Callback function contains two parameters: pageNumber: the number of pages of the new page pageSize: the size of the new page onBeforeRefresh pageNumber, pageSize is triggered before the refresh button is clicked, if false is returned, the refresh operation is canceled onRefresh pageNumber, pageSize is triggered after refreshing onChangePageSize pageSize is triggered when the page size is changed Demo

1. Data extraction and display.

DataGrid obtains data through the url attribute. For example: url:'ListInfo.action', in this way, the data is obtained by calling the method in Action. What is returned is a JSON string. Note that JSON strings must be assembled according to the data format defined by DataGrid. For this data format, you can refer to the attachment in my previous article. It is particularly emphasized that the value of the total field in the JSON string is the number of data items, which is used for data paging.

2. Data paging.

Data paging is divided into foreground paging and background paging. Foreground paging, DataGrid has been encapsulated. DataGrid defines two parameters: rows (number of items per page) and page (current page number). These two parameters correspond to the attributes pageSize and pageNumber respectively. The user can set it in the pageSize and pageNumber attributes, or not set it, so the default value is used. We only need to define two variables in Action, private int rows; private int page; and then obtain the required values ​​through SQL statements. The paging SQL statement (Oracle) is as follows:

Assign the number of extracted data to the total field, assemble it and return it in a JSON string, and you can achieve paging. Of course, pagination:true, is certainly required.

3. Data operations.

Data operations can be roughly divided into: viewing and deleting. For viewing, we can achieve this through onClickRow or onDblClickRow events. For example:

$(function(){

$('#test').datagrid({

title:'数据列表',

width:900,

height:500,

.......(省略的属性)

onDblClickRow: function() {

var selected = $('#test').datagrid('getSelected');

if (selected){

window.open("DataView.action?Id="+selected.ID);

}}
Copy after login

You can view it by double-clicking it.

Regarding deletion, you can click the delete button and call the delete method. The delete button can be assigned to the OPERATION field when assembling the JSON string. By setting {field:'OPERATION', title: 'Operation', width: 120}, the delete button can be displayed on the page. The implementation of deletion is as follows:

function DelAff(){

$.messager.confirm('确认','是否真的删除?',function(r){ 

if (r){ 

var selected = $('#test').datagrid('getSelected');

if (selected){

var index = $('#test').datagrid('getRowIndex', selected);

$('#test').datagrid('deleteRow', index);

DeleteSubmit(selected);

}

}

});

}

function DeleteSubmit(selected)

{

var url="DataDelete.action?Id="+selected.ID;

$.post(

url     

);

}
Copy after login

In this way, both page deletion and database deletion are realized.

4. Problems to be solved

If the returned data is empty, there will be a bug in the page under IE browser. My solution is to set each field to "", so that a row of empty content data will appear on the page. If you have encountered this problem and solved it, please give me some advice.

The above is the detailed content of jquery easyui paging tutorial examples. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tutorial on how to use Dewu Tutorial on how to use Dewu Mar 21, 2024 pm 01:40 PM

Dewu APP is currently a very popular brand shopping software, but most users do not know how to use the functions in Dewu APP. The most detailed usage tutorial guide is compiled below. Next is the Dewuduo that the editor brings to users. A summary of function usage tutorials. Interested users can come and take a look! Tutorial on how to use Dewu [2024-03-20] How to use Dewu installment purchase [2024-03-20] How to obtain Dewu coupons [2024-03-20] How to find Dewu manual customer service [2024-03-20] How to check the pickup code of Dewu [2024-03-20] Where to find Dewu purchase [2024-03-20] How to open Dewu VIP [2024-03-20] How to apply for return or exchange of Dewu

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

In summer, you must try shooting a rainbow In summer, you must try shooting a rainbow Jul 21, 2024 pm 05:16 PM

After rain in summer, you can often see a beautiful and magical special weather scene - rainbow. This is also a rare scene that can be encountered in photography, and it is very photogenic. There are several conditions for a rainbow to appear: first, there are enough water droplets in the air, and second, the sun shines at a low angle. Therefore, it is easiest to see a rainbow in the afternoon after the rain has cleared up. However, the formation of a rainbow is greatly affected by weather, light and other conditions, so it generally only lasts for a short period of time, and the best viewing and shooting time is even shorter. So when you encounter a rainbow, how can you properly record it and photograph it with quality? 1. Look for rainbows. In addition to the conditions mentioned above, rainbows usually appear in the direction of sunlight, that is, if the sun shines from west to east, rainbows are more likely to appear in the east.

Tutorial on how to turn off the payment sound on WeChat Tutorial on how to turn off the payment sound on WeChat Mar 26, 2024 am 08:30 AM

1. First open WeChat. 2. Click [+] in the upper right corner. 3. Click the QR code to collect payment. 4. Click the three small dots in the upper right corner. 5. Click to close the voice reminder for payment arrival.

What software is photoshopcs5? -photoshopcs5 usage tutorial What software is photoshopcs5? -photoshopcs5 usage tutorial Mar 19, 2024 am 09:04 AM

PhotoshopCS is the abbreviation of Photoshop Creative Suite. It is a software produced by Adobe and is widely used in graphic design and image processing. As a novice learning PS, let me explain to you today what software photoshopcs5 is and how to use photoshopcs5. 1. What software is photoshop cs5? Adobe Photoshop CS5 Extended is ideal for professionals in film, video and multimedia fields, graphic and web designers who use 3D and animation, and professionals in engineering and scientific fields. Render a 3D image and merge it into a 2D composite image. Edit videos easily

See all articles