jQuery插件dataTables使用Ajax通过Action点击下一步传数据
1.前端js代码
1).<script src="/scm/js/jquery-1.3.2.js" type="text/javascript"></script>
2).<script type="text/javascript" language="javascript" src="jqtables/js /jquery.dataTables.js"></script>
$(function(){ var oTable = $('#datatable').dataTable({ 'bJQueryUI': true, "bProcessing":true, "bServerSide": true, "iDisplayStart":0, "iDisplayLength": 5, "sAjaxSource":"region_safe_home _json.action?region.id=1", "sAjaxDataProp":"applyInfoList", "aoColumns": [ { "mDataProp": "id" }, { "mDataProp": "resource.resourceName" }, { "mDataProp": "operateTypeName" }, { "mDataProp": "applyUser" }, { "mDataProp": "statusName" }, { "mDataProp": "createTime"} ], 'sPaginationType': 'full_numbers', 'bSort':false, }); });
3).HTML代码中table的id为datatable
2.Action中
private int curPage; private String iTotalRecords; //向前端返回数据需要的JSON对象 private String iTotalDisplayRecords;//向前端返回数据需要的JSON对象 private int iDisplayLength; private int iDisplayStart; public String applyHome() throws ServiceException{ return SUCCESS; } public String applyList() throws ServiceException{ int displayLength = iDisplayLength; int displayStart = iDisplayStart ; applyInfoList = this.getApplyInfoManager().findApplyInfoByRegion(region); int totalNum = applyInfoList.size(); int pageCount = totalNum/displayLength; int remainder = totalNum%displayLength; if(remainder != 0){ pageCount = pageCount + 1; } iTotalRecords = totalNum+""; iTotalDisplayRecords = totalNum+""; curPage = displayStart/displayLength+1; int startNum = displayStart; int endNum = 5; startNum = displayLength*(curPage-1); if(remainder != 0){ if(curPage == pageCount){ endNum = startNum + remainder; }else{ endNum = startNum+displayLength; } }else { endNum = startNum+displayLength; } applyInfoList = applyInfoList.subList(startNum, endNum); return SUCCESS; }
相关推荐
85477104 2020-11-17
TONIYH 2020-07-22
83510998 2020-07-18
wcqwcq 2020-06-26
delmarks 2020-06-14
ppsurcao 2020-06-14
tthappyer 2020-06-07
EdwardSiCong 2020-11-23
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08