easyuidatagrid分页Word下载.docx
《easyuidatagrid分页Word下载.docx》由会员分享,可在线阅读,更多相关《easyuidatagrid分页Word下载.docx(14页珍藏版)》请在冰豆网上搜索。
2.定义查询信息类,继承基类
上图中的红圈信息为查询信息,及一些业务逻辑信息都包含进去。
packagemon.dto;
importjava.util.List;
importmon.util.PaginatedHelper;
publicclassPaginateextendsPaginatedHelper{
privatestaticfinallongserialVersionUID=1L;
privateStringapplyDateStart;
privateStringapplyDateEnd;
privateDepartmentInfodepartmentCode;
privateBranchInfobranchCode;
privateStringbusinessSeries;
publicStringgetApplyDateStart(){
returnapplyDateStart;
publicvoidsetApplyDateStart(StringapplyDateStart){
this.applyDateStart=applyDateStart;
publicStringgetApplyDateEnd(){
returnapplyDateEnd;
publicvoidsetApplyDateEnd(StringapplyDateEnd){
this.applyDateEnd=applyDateEnd;
publicDepartmentInfogetDepartmentCode(){
returndepartmentCode;
publicvoidsetDepartmentCode(DepartmentInfodepartmentCode){
this.departmentCode=departmentCode;
publicBranchInfogetBranchCode(){
returnbranchCode;
publicvoidsetBranchCode(BranchInfobranchCode){
this.branchCode=branchCode;
publicStringgetBusinessSeries(){
returnbusinessSeries;
publicvoidsetBusinessSeries(StringbusinessSeries){
this.businessSeries=businessSeries;
List<
String>
list;
publicList<
getList(){
returnlist;
publicvoidsetList(List<
list){
this.list=list;
}
3.前台页面:
<
%@pagelanguage="
java"
contentType="
text/html;
charset=utf-8"
pageEncoding="
utf-8"
%>
%@includefile="
/WEB-INF/views/commons/head.jsp"
html>
head>
title>
/title>
scripttype="
text/javascript"
src="
${ctx}resources/DatePicker/WdatePicker.js"
>
/script>
script>
functionqueryAction(){
varwd=$("
#tt"
).width();
vardata=$("
#form1"
).serialize();
varsend_url="
c:
urlvalue='
JosnDataNewPaginate.do'
/>
?
"
+data;
$('
#tt'
)
.datagrid(
{
title:
'
订单信息'
url:
send_url,
rownumbers:
true,
columns:
[[
{
field:
chk'
width:
wd*0.07,
align:
"
center"
formatter:
function(value,row){
varf=row.curStorehouseNo==row.toStorehouseNo
&
&
row.flag=='
Y'
;
return"
inputtype='
checkbox'
name='
ckbox'
+(f==true?
'
:
disabled'
+"
value='
+row.voucherFittingNo
}
},
voucherFittingNo'
title:
调拨单号'
sortable:
wd*0.1,
sorter:
function(a,b){
return(a>
b?
1:
-1);
branchName'
申请机构'
wd*0.13
toStorehouseName'
申请仓库'
wd*0.15
voucherCode'
单证代码'
wd*0.08
voucherName'
单证名称'
fittingSum'
申请调拨数量'
right'
wd*0.1
fromStorehouseName'
调出仓库'
fittingStatusDesc'
调拨单状态'
voucherFittingNoLink'
审批信息'
ahref='
showReviewList.do?
fittingNo="
审批结果<
/a>
}]],
pagination:
true
});
document.getElementById("
optionTable"
).style.display="
$(document).ready(function(){
$("
#sub1"
).bind({
click:
queryAction
});
//queryAction();
});
/head>
body>
<
form:
formmodelAttribute="
voucherFitting"
method="
post"
name="
form1"
id="
<
divclass="
layout_div"
<
navigation_div"
!
--定义导航条-->
spanclass="
font_heading1"
您的当前位置:
库存管理&
gt;
/span>
ahref="
${ctx}/inventory/fittingMaintain/showSelect.do"
调拨单状态查询与维护<
/div>
<
tableborder="
0"
width="
100%"
class="
layouttable"
<
tr>
<
tdwidth="
12%"
layouttable_td_label"
调拨单申请时间:
/td>
50%"
layouttable_td_widget"
inputname="
applyDateStart"
Wdateeasyui-validateboxinput_text"
onFocus="
WdatePicker({skin:
whyGreen'
maxDate:
#F{$dp.$D(\'
applyDateEnd\'
)||\'
%y-%M-%d+1\'
}'
})"
value="
${applyDateStart}"
required="
true"
missingMessage="
请选择起始时间"
nbsp;
至&
applyDateEnd"
${applyDateEnd}"
minDate:
applyDateStart\'
)}'
%y-%M-%d+1'
请选择结束时间"
tdalign="
right"
aclass="
easyui-linkbutton"
sub1"
iconCls="
icon-search"
>
查询<
/tr>
tdcolspan="
4"
errorspath="
*"
cssClass="
requred_font"
/table>
tableid="
tt"
style="
display:
none"
tr>
align="
<
onclick="
javascript:
modify()"
icon-edit"
修改<
invalid()"
icon-remove"
作废<
exportFitting()"
icon-ok"
导出报表<
/form:
form>
/body>
/html>
主要注意,在页面中的输入字段的命名跟上面查询信息类Paginate的field字段命名一直,或使用sf标签的绑定规则来将前台页面绑定到Paginate类。
4.Controller中查询信息读取:
*jquery分页
@RequestMapping(value="
/JosnDataNewPaginate"
publicvoidgetJsonDataGrid(HttpServletRequestrequest,
HttpServletResponseresponse,PaginatepaginateInfo)throwsException{
VoucherFitting>
fittingList=fittingMaintainService.retrieveFitting(paginateInfo);
//调用Service中的查询方法的到显示数据list
inttotalCount=fittingMaintainService.retrieveFittingCount(paginateInfo);
//调用Service中方法到总记录数
PrintWriterwrite=response.getWriter();
JSONObjecto=newJSONObject();
o.put("
total"
totalCount);
rows"
list);
write.write(o.toString());
System.out.print(o.toString());
write.flush();
write.close();
o.clear();
5.分页数据的结构定义:
fittingList=fittingMaintainService.retrieveFitting(paginateInfo);
VoucherFitting定义为Map类型,包含前台展示的filed和显示信息。
由于在DOMIAN中和SQL中必须传入分页信息,startRow(起始条)和endRow(结束条),用于返回数据,可以使用上面Controller的getJsonDataGrid中,
intstartRow=paginateInfo.getStartIndex();
intendRow=paginateInfo.getStartIndex()+paginateInfo.getPageSize;
6.ibatis配置文件中SQL分页语句写法参考:
先定义一个公用分页SQLXML文件:
如commons-ibatis2.xml,做下列定义:
xmlversion="
1.0"
encoding="
UTF-8"
DOCTYPEsqlMapPUBLIC"
-//ibatis.apache.org//DTDSQLMap2.0//EN"
http:
//ibatis.apache.org/dtd/sql-map-2.dtd"
sqlMapnamespace="
commons"
--定义综合查询前缀,后缀sql-->
sqlid="
prefixSql"
dynamic>
isEqualproperty="
doCount"
compareValue="
selectcount(*)from(
/isEqual>
false"
SELECT*FROM(selectrow_.*,rownumstart_rownum_from
(
/dynamic>
/sql>
suffixSql"
)<
[CDATA[
)row_WHERErownum<
=#startIndex#+#pageSize#)WHEREstart_rownum_>
#startIndex#
]]>
countPrefix"
selectcount(*)from(<
countSuffix"
pagePrefix"
isNotNullproperty="
pageSize"
SELECT*FROM(selectrownumr,union_tb.*from(
/isNotNull>
pageSuffix"
)union_tb
)WHEREr>
#startIndex#ANDr<
=#startIndex#+#pageSize#
/sqlMap>
则分页查询ibatis文件定义可以参照如下:
sqlMap
namespace="
com.sinolife.uw.formTaskReassign.integration.dao.FormTaskReassignDao"
--查询信息结果匹配-->
resultMapid="
FormTaskReassignListInfo.ResultMap"
class="
com.sinolife.uw.domain.FormTaskReassignListDomain"
resultproperty="
applyBarCode"
column="
APPLY_BAR_CODE"
/>
channelTypeDesc"
DOCUM