这篇文章主要介绍了JSP+EXt2.0实现分页的方法,涉及JavaScript结合JSP遍历及分页的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了JSP+EXt2.0实现分页的方法。分享给大家供大家参考。具体如下:
JavaScript代码:
Ext.onReady(function(){ var sm = new Ext.grid.CheckboxSelectionModel(); var cm = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), sm, {header:'编号',dataIndex:'id',sortable:true}, {header:'名称',dataIndex:'name',sortable:true}, {header:'性别',dataIndex:'sex',sortable:true,renderer:function(value){ if(value=='male'){ return " <span style='color:red;font-weight:bold'>红男 </span>"; }else{ return " <span style='color:green;font-weight:bold'>绿女 </span>"; } }}, {header:'<em style="color:transparent">来源[email protected]搞@^&代*@码网</em>描述',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: 'name',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, trackMouseOver:false, loadMask: {msg:'正在加载数据,请稍侯……'}, store:ds, cm: cm, sm:sm, bbar: new Ext.PagingToolbar({ pageSize: 5, store: ds, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "No topics to display" }) }); grid.render(); ds.load({params:{start:0, limit:5}}); });
JSP代码:
<% 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
希望本文所述对大家的JSP程序设计有所帮助。
以上就是JSP+EXt2.0实现分页的方法的详细内容,更多请关注gaodaima搞代码网其它相关文章!