Jsp+ext2.0 method of implementing paging _jsp programming

Source: Internet
Author: User

The example of this article describes the jsp+ext2.0 implementation of pagination method. Share to everyone for your reference. Specifically as follows:

JavaScript code:

Ext.onready (function () {var sm = new Ext.grid.CheckboxSelectionModel (); var cm = new Ext.grid.ColumnModel ([New ext.gr Id. 
    Rownumberer (), SM, {header: ' numbered ', dataindex: ' ID ', sortable:true}, {header: ' name ', Dataindex: ' Names ', sortable:true}, {header: ' Gender ', dataindex: ' Sex ', sortable:true,renderer:function (value) {if (value== ' male ') {return ' <span Style= ' Color:red;font-weight:bold; ' 
    > Red male </span>  '; }else{return "<span style= ' color:green;font-weight:bold; ' 
    > Green Women </span>  '; 
  }}, {header: ' description ', dataindex: ' Descn ', 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: ' Totalproperty ', root: ' Root '}, [{name: ' ID ', mapping: ' ID '}, {name: ' Nam E ', Mapping: ' name '}, {name: ' Sex ', Mapping: ' Sex '}, {name: ' DESCN ', Mapping: ' DESCN '}], remotesort:true}); var Grid = new Ext.grid.GridPanel ({el: ' Grid ', title: ' Ext grid Test ', width:450, height:410, Trackmouseove R:false, Loadmask: {msg: ' Loading data, please wait ... '}, Store:ds, cm:cm, SM:SM, bbar:new ext.pagingtoolbar ({page Size:5, Store:ds, Displayinfo:true, displaymsg: ' currently displaying {0}-{1} Records/Total {2} records ', Emptymsg: "N 
  O 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 the JSP program design.

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.