我正在使用dojox.grid.DataGrid顯示網格中的數據。目前數據庫中有50條記錄,所以它在網格中顯示50條記錄(請參閱此處的UI)如何使用dojox.grid.DataGrid實現分頁
是否有可能告訴dojox.grid.DataGrid每頁顯示10條記錄。 意思是我想每頁只顯示10條記錄,如果用戶在分頁下點擊2頁,它應該顯示下10條記錄。
請告訴我,如果這是可能的?
這是我的JSP頁面:
<body class=" claro ">
<span dojoType="dojo.data.ItemFileReadStore" jsId="store1" url="http://localhost:8080/Man/MyServlet2"></span>
<table dojoType="dojox.grid.DataGrid" store="store1"
style="width: 100%; height: 500px;">
<thead>
<tr>
<th width="150px" field="name">Name</th>
<th width="150px" field="dept">Dept</th>
</tr>
</thead>
</table>
這是我的servlet代碼:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/x-json;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
System.out.print("MyservletSAA called");
PrintWriter out = response.getWriter();
List list = new ArrayList();
for (int i = 0; i < 50; i++) {
Employee emp = new Employee();
emp.setDept("MyDept" + i);
emp.setName("MYName" + i);
list.add(emp);
}
JSONObject json = new JSONObject();
json.put("items", list.toArray());
response.getWriter().write(json.toString());
}
看到這個問題的工作網格的一個例子小提琴:http://stackoverflow.com/questions/15269985/dojo-enhanced-grid-with-pagination-need-to-access-number-of-rows-in-the -頁。 – Jess