LigerUI Grid服务端分页技术
Grid部分:
$("#grid").ligerGrid({
title:'串码文件管理',
height:$(document).height()-5,
checkbox:true,
columns: [
{ display: '串码编号',name: 'id', align: 'left', width: 100, minWidth: 60 },
{ display: '串码', name: 'code', minWidth: 220 },
{
display: '有效性', name: 'valid', minWidth: 120,
render:function(item){
if(item.valid==0)
{
return '<span class="red">已经使用过的</span>';
}else if(item.valid==1){
return '<span class="blue">有效的</span>';
}
}
}],
url:'/admin/getAllSequence',
pageSize:20,
usePager:true,
toolbar: {
items: [
{ text: '批量上传串码', click:this.add, icon: 'add' },
{ line: true },
{ text: '删除', click: this.remove,icon:'delete' }
]
}
});
服务端部分:
public String getAllSequence()
{
/**
* 返回所有串码列表
*/
dataMap.clear();
//分页相关
String page=request.getParameter("page");
String pagesize=request.getParameter("pagesize");
if(!StringUtils.isBlank(page)&&!StringUtils.isBlank(pagesize))
{
int start=Integer.parseInt(page);
int limit=Integer.parseInt(pagesize);
HashMap<String,Integer> map=new HashMap<String,Integer>();
map.put("start", start*limit-limit);
map.put("limit", limit);
dataMap.put("Rows", getShop().getSeqByPage(map));
}
dataMap.put("Total", getShop().getSeqCount());
return SUCCESS;
}