2011-07-09 75 views
2

我正在使用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()); 

} 
+2

看到這個問題的工作網格的一個例子小提琴:http://stackoverflow.com/questions/15269985/dojo-enhanced-grid-with-pagination-need-to-access-number-of-rows-in-the -頁。 – Jess

回答

0
+0

請注意[僅限鏈接回答](http://meta.stackoverflow.com/tags/link-only-answers/info),所以答案應該是搜索解決方案的終點(vs.而另一個引用的中途停留時間往往會隨着時間推移而過時)。請考慮在此添加獨立的摘要,並將鏈接保留爲參考。 – kleopatra