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.