基于jqGrid实现列表分页效果(后台处理以及pageBean)
来源:互联网 发布:巨库软件 编辑:程序博客网 时间:2024/05/21 01:43
基于jqGrid实现列表分页效果(后台处理)
目录
[TOC]
分页实现布局:
前端使用jqGrid配置实现分页展示
后台创建分页javaBean
后台handler实现分页
前端使用jqGrid配置实现分页展示
jqGrid实现列表的展示功能,通过配置实现分页查询, —— [ jqGrid参考资料 ]
代码块
jsonReader: {/* rows: 后台返回数据list集合 currPage: 当前页 totalpages: 总页数 totalCount: 总记录数*/ root:"rows", page:"currPage", total:"totalpages", // 很重要 定义了 后台分页参数的名字。 records:"totalCount", repeatitems:false, id : "id" }
后台创建分页pageBean
代码块
package com.kingdee.eas.custom.database.certificate;public class CertificateQueryPage { private int curPage =1; //当前页 private int totalPage; // 总页数 private int totalCount; // 总行数 private int pageSize=20; // 每页行数 public CertificateQueryPage(int rows, Integer curPage,Integer pageSize){ this.totalCount = rows; this.curPage = curPage; this.pageSize=pageSize; if(this.totalCount % this.pageSize ==0){ this.totalPage = this.totalCount/this.pageSize; }else if (rows < this.pageSize){ this.totalPage =1; }else{ this.totalPage = this.totalCount/this.pageSize +1; } } public CertificateQueryPage(int rows) { this.totalCount=rows; if(this.totalCount % this.pageSize ==0){ this.totalPage =this.totalCount/this.pageSize; }else if(rows < this.pageSize){ this.totalPage=1; }else { this.totalPage =this.totalCount/this.pageSize +1; } } public int getCurPage() { return curPage; } public void setCurPage(int curPage) { this.curPage = curPage; } public int getTotalPage() { return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; } public int getTotalCount() { return totalCount; } public void setTotalCount(int totalCount) { this.totalCount = totalCount; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; }}
后台handler实现分页
代码块
// 分頁 String page = request.getParameter("page"); String pageSizeR = request.getParameter("rows"); CertificateQueryPage queryPage =null; if(!StringUtils.isEmpty(page) || !StringUtils.isEmpty(pageSizeR)){ queryPage = new CertificateQueryPage(dataList.size(),Integer.valueOf(page),Integer.valueOf(pageSizeR)); }else{ queryPage = new CertificateQueryPage(dataList.size()); } //CertificateQueryPage int pageSize = queryPage.getPageSize(); int curPage = queryPage.getCurPage(); int fromIndex =(curPage -1)*pageSize;//开始索引 int toIndex = curPage*pageSize;// 结束索引 if(toIndex> queryPage.getTotalCount()){// 如果结束索引大于list的size,则结束索引等于lise的size toIndex =queryPage.getTotalCount(); } if(fromIndex > toIndex){// 如果开始索引大于结束索引,则 fromIndex=0; } // dataList为数据总量,这里通过subList函数返回分页结果数据 // gridDataMap 为后台返回前端的Map gridDataMap = new LinkedHashMap()数据集;这里使用LinkedHashMap的目的,保证数据排序前后端不混乱 List list = dataList.subList(fromIndex, toIndex); gridDataMap.put("rows", list); gridDataMap.put("currPage", curPage); gridDataMap.put("totalpages", queryPage.getTotalPage()); gridDataMap.put("totalCount", queryPage.getTotalCount());
阅读全文
0 0
- 基于jqGrid实现列表分页效果(后台处理以及pageBean)
- PageBean方式实现分页效果 泽0715
- pageBean实现分页
- PageBean方式实现分页效果 &n…
- 分页的pageBean的实现
- 基于hibernate的分页程序的实现(后台)
- JqGrid实现分页相关
- hibernate+pageBean实现分页dao层功能代码
- struts 分页的pageBean
- 分页jsp PageBean
- 分页中的PageBean
- 用于分页的PageBean
- 分页功能之PageBean
- 自定义分页实例PageBean
- 【JqGrid】JqGrid使用后台分页+查询条件+排序
- 基于c#bindingDateSource Datagridview 实现分页效果
- JQuery中jqGrid分页实现
- JQuery中jqGrid分页实现
- Linux入门
- 余承东吐槽iPhone X长的丑体验差;雷军称小米明年要进世界500强;特斯拉股价被指太荒唐丨价值早报
- 程序员幽默:66条让你笑爆肚皮的程序员段子
- 创投日报:11月3日至5日收录投融资项目13起
- Android编程权威指南第三版挑战练习一
- 基于jqGrid实现列表分页效果(后台处理以及pageBean)
- leetcode23. Merge k Sorted Lists
- CSS3实现文字流光渐变特效
- html+css
- 开始注重身体这部分的男士,大都撩到妹了 | 钛空实测
- MacBook上那些好用的工具们
- bitcoin百喻经-通俗原理
- ARM处理器工作模式详解
- 这位CEO“疯”了,无人驾驶卡车夜间“飙车”全程曝光