基於SSH架構、Oracle資料庫、easyui的分頁顯示

來源:互聯網
上載者:User

標籤:

要求:在easyui-datagrid中完成paginaton的分頁功能。

1.easyui-datagrig的配置

<table id="dg" rownumbers=true fitColumns="true" singleSelect="true"data-options="pagination:true,fit:true,toolbar:‘#tt‘"><thead><tr><th field="bNo" align="center" width="120px">櫃員號</th><th field="bType" align="center" width="150px">櫃員類型</th><th field="jGNo" align="center" width="120px">機構號</th><th field="pZCount" align="center"  width="120px">憑證數</th><th field="zJcount" align="center"  width="120px">主件數</th><th field="fJcount" align="center"  width="120px">附件數</th><th field="sBPass" align="center"  width="150px">識別憑證</th><th field="sBSuccess" align="center"  width="150px">識別成功</th><th field="sBRoute" align="center"  width="120px">識別率</th><th field="yWDate" align="center"  width="170px">業務日期</th></tr></thead></table>

  pagination="true"資料表格會自動將分頁欄置於表下方;toolbar="#tt"表示為資料表格上方加入工具列,具體樣式是id="#tt"的模組決定的。在看下js檔案對datagrid的其他配置:

$(‘#dg‘).datagrid({url:‘user/queryList.action‘,pageList: [5,10,20,50,100],     pageSize:5});

  url為頁面重新整理datagrid自動的請求,每次請求會向後台傳入兩個參數:1)page,當前第幾頁;2)rows,每頁顯示幾條資料。因此在後台需要就收這兩條重要訊息。

2.struts2的Action配置

public String queryList(){List<User> list = userService.queryList(page,rows) ;pag1 = new Pagination<User>();pag1.setTotal(userService.getCount());pag1.setRows(list);return SUCCESS ;}
<package name="work" namespace="/user" extends="json-default,struts-default"><action name="queryList" class="userAction" method="queryList"><result type="json"><param name="root">pag1</param></result></action>
</package>

 pag1為DTO資料轉送對象,有total和rows兩屬性(datagrid要求的json格式)

3.hibernate層service分頁方法

public List<User> queryList(int page, int pageSize) {// TODO Auto-generated method stubString hql = "from User";Query query = userDao.getSession().createQuery(hql);int beginNum = (page-1)*pageSize;int endNum = beginNum+pageSize>getCount()?getCount()-beginNum :pageSize ;query.setMaxResults(endNum);  query.setFirstResult(beginNum);  return query.list();}

  

 

基於SSH架構、Oracle資料庫、easyui的分頁顯示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.