How to achieve Pagination with dojox.grid.DataGrid
I am using dojox.grid.DataGrid for displaying Data inside a Grid . Currently there are 50 Records in the Databse so its displaying 50 Records in the Grid (Please see the UI here )
Is it possible to tell dojox.grid.DataGrid to display 10 Records per page . Means i want to show only 10 Records per page , if the user clicks on 2 Page under pagination it should display the next 10 Records .
Please tell me if this is possible ??
This is my JSP page :
<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>
This is my servlet Code :
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());
}
Quite old post, but maybe it'll help someone:
http://dojotoolkit.org/reference-guide/1.9/quickstart/data/usingdatastores/pagination.html
精彩评论