Home > Web Front-end > JS Tutorial > EasyUi datagrid implements table paging_jquery

EasyUi datagrid implements table paging_jquery

WBOY
Release: 2016-05-16 16:14:46
Original
1198 people have browsed it

1. First introduce the css and js files of easyui

2. The js that needs to be written at the front desk

Copy code The code is as follows:

//Source data
function Async(action,args,callback){
$.ajax({
 url: action ,
​type:"POST",
​dataType:"json",
Timeout: 10000,
​data: args,
Success: function(data){
​​if(callback){
​ callback(data);
}
}
});
}
//Bind data and set paging
function BingData(pid,args,action,callback){
Async(action,args,function(data){
if(data!=null&&data.list!=null){
var _dataCount=data.size;//Total number of items
var _data=data.list;//data
if(callback){
callback(_data);
}
$(pid).datagrid('loadData', _data);
$(pid).datagrid('getPager').pagination({
beforePageText: 'th',
afterPageText: 'Page {pages}',
displayMsg: 'Currently displaying {from} - {to} records, a total of {total} records',
pageSize: args.pageSize,
total: _dataCount,
pageNumber: args.pageIndex,
pageList:args.pageList,
onSelectPage: function (pageNumber, pageSize) {
args.pageIndex = pageNumber;
args.pageSize = pageSize;
BingData(pid, args, action,null);
},
onRefresh: function (pageNumber, pageSize) {
args.pageIndex = pageNumber;
args.pageSize = pageSize;
BingData(pid, args, action,null);
}
});
}
});
}
//Serialize the form into an object
$.fn.serializeObject = function(){
var obj = {};
$.each( this.serializeArray(), function(i,o){
var n = o.name, v = o.value;
obj[n] = obj[n] === undefined ? v
: $.isArray( obj[n] ) ? obj[n].concat( v )
: [ obj[n], v ];
});
return JSON.stringify(obj);
};
//Width
function fixWidth(percent){
return document.body.clientWidth * percent ;
}
//End editing
function endEdit(vid){
vid = "#" vid;
var tb=$(vid);
var rows = tb.datagrid('getRows');
for ( var i = 0; i < rows.length; i ) {
tb.datagrid('endEdit', i);
}
}
function GetData(obj){
var url = contextPath '/fundRetreatVoucher/fundBatchRetreatVoucherQuery.htm';//action path
var args={};
args.pageIndex=1;//Page index
args.pageSize=10;//Page capacity
if(obj!=null){ //Form serialized object
args.obj=obj;
}
BingData("#tab",args,url,null);
}
function getTab(){
GetData();
var tb=$('#tab');
tb.datagrid({
title: 'Fund return batch query results',
striped: true,
fitColumns: true, //Adaptive column size
rownumbers: true,
nowrap: true, //Set to true, when the data length exceeds the column width, it will be automatically intercepted
striped: true,
width:fixWidth(0.99),
height:'430',
singleSelect:true,
loadMsg: 'Data loading...',
columns:[[
{field:'interfaceInfoCode',title:'Capital Channel Code',width:fixWidth(0.3),align: "center"},
              {field:'retreatBatchCode',title:'Funds Return Batch Number',width:fixWidth(0.2),editor:'text',align: "center"},
                                                                                                                                                                                  {field:'totalMoney',title:'total amount',width:fixWidth(0.1),align:'right',editor:'text',align: "center"},
{field:'def2',title:'Operation',width:fixWidth(0.3),editor:'text',align:'right',align: "center",
formatter:function(value,row,index){
  var vcode =row.retreatBatchCode;
  var e = 'Details | ';
  var d = 'Audit passed | ';
  var f = 'Audit rejection ';
  return e d f;
  }}
]],
onLoadSuccess:function(data){
​if (data.total == 0) {
}
},
Pagination: true,
pageIndex:1,//Page index
pageSize:10,//Page capacity
pageList: [10,15,20]
})
}

2 Backstage

Copy code The code is as follows:

int currentPage = request.getParameter("pageIndex") == null ? 1 : Integer.parseInt(request.getParameter("pageIndex"));
//Number of lines per page
int showCount = request.getParameter("pageSize") == null ? 10 : Integer.parseInt(request.getParameter("pageSize"));
// Pagination entity
String obj = request.getParameter("obj");
if (StringUtils.notBlank(obj)) {
fundRetreatVoucher = JsonUtils.toObject(obj, FundRetreatVoucherParam.class); //Convert form serialized json object to entity
}
out = response.getWriter();
List frvs = fundRetreatVoucherService.findAllFundRetreatVoucher(page, fundRetreatVoucher);
int total = fundRetreatVoucherService.findAllFundRetreatVoucher(getTotal(), fundRetreatVoucher).size();//data size
JSONObject json = new JSONObject();
json.put("list", frvs);//Data, the key of put here must be list. If it is changed, you need to change the data in BingData
json.put("size", total);
out.print(json);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template