JSP+EXt2.0實現分頁的方法_JSP編程

來源:互聯網
上載者:User

本文執行個體講述了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> <img src='./img/125.gif'>";     }else{      return " <span style='color:green;font-weight:bold;'>綠女 </span> <img src='./img/123.gif'>";     }    }},     {header:'描述',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代碼:

<%@ 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); %>

希望本文所述對大家的JSP程式設計有所協助。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.