JSP + EXt2.0 implements paging, and jspext2.0 implements Paging

Source: Internet
Author: User

JSP + EXt2.0 implements paging, and jspext2.0 implements Paging

This example describes how to implement paging in JSP + EXt2.0. Share it with you for your reference. The details are as follows:

JavaScript code:

Ext. onReady (function () {var sm = new Ext. grid. checkboxSelectionModel (); var cm = new Ext. grid. columnModel ([new Ext. grid. rowNumberer (), sm, {header: 'number', dataIndex: 'id', sortable: true}, {header: 'name', dataIndex: 'name', sortable: true}, {header: 'gender', dataIndex: 'sex', sortable: true, renderer: function (value) {if (value = 'male ') {return "<span style = 'color: red; font-weight: bold; '> male </span>  ";} Else {return" <span style = 'color: green; font-weight: bold;'> green female </span>  ";}},{ header: 'description', dataIndex: 'desc', sortable: true}]); cm. defaultSortable = true; var ds = new Ext. data. store ({proxy: new Ext. data. httpProxy ({url: 'page. jsp '}), reader: new Ext. data. jsonReader ({totalProperty: 'totalproperties', root: 'root'}, [{name: 'id', mapping: 'id'}, {name: 'name', mapping:' Name'}, {name: 'sex ', mapping: 'sex'}, {name: 'desc', mapping: 'desc'}]), remoteSort: true }); var grid = new Ext. grid. gridPanel ({el: 'grie', title: 'ext grid test', width: 450, height: 410, trackMouseOver: false, loadMask: {msg: 'loading data, please wait ...... '}, Store: ds, cm: cm, sm: sm, bbar: new Ext. pagingToolbar ({pageSize: 5, store: ds, displayInfo: true, displayMsg: 'currently {0}-{1} records/{2} records in total ', emptyMsg: "No topics to display"}); grid. render (); ds. load ({params: {start: 0, limit: 5 }});});

JSP code:

<%@ page language="java" pageEncoding="UTF-8"%><% String start = request.getParameter("start"); String limit = request.getParameter("limit");int index = Integer.parseInt(start); int pageSize = Integer.parseInt(limit); String json = "{totalProperty:100,root:["; String sex="";for (int i = index; i < pageSize + index; i++) { if(i%2==0){  sex="male";}else{  sex="female";}  json += "{id:" + i + ",name:'" + i + "',sex:'"+sex+"',descn:'descn" + i   + "'}";   if (i != pageSize + index - 1) {   json += ",";   } } json += "]}"; response.getWriter().write(json); System.out.print(json); %>

I hope this article will help you with JSP program design.

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.