首页 技术 正文
技术 2022年11月17日
0 收藏 575 点赞 2,204 浏览 2169 个字

系列索引

Web jquery表格组件 JQGrid 的使用 – 从入门到精通 开篇及索引

Web jquery表格组件 JQGrid 的使用 – 4.JQGrid参数、ColModel API、事件及方法

Web jquery表格组件 JQGrid 的使用 – 5.Pager翻页、搜索、格式化、自定义按钮

Web jquery表格组件 JQGrid 的使用 – 6.准备工作 & Hello JQGrid

Web jquery表格组件 JQGrid 的使用 – 7.查询数据、编辑数据、删除数据

Web jquery表格组件 JQGrid 的使用 – 8.Pager、新增数据、查询、刷新、查看数据

Web jquery表格组件 JQGrid 的使用 – 全部代码

Web jquery表格组件 JQGrid 的使用 – 11.问题研究

JQGrid导出Excel文件

使用Jqgrid时突然发现 数据类型为local时,

datatype: 'local',
data:datas,
rowNum: 10,
rowList: [10],

指定data的datas长度大于rowNum时,pager点击下一页最后一页都是无效的

使用

$(grid)[0].addJSONData(jsongrid);

也一样无效。

搜索发现不少使用

http://stackoverflow.com/questions/5537728/jqgrid-pager-not-working-with-local-datatype

localReader或者jsonReader但我测试无效
var grid = $('#table').jqGrid({
datatype: 'local',
altRows: true,
colModel: [
{name: '0', label: "Name"},
{name: '1', label: "Color"},
],
pager: "#pager",
rowNum: 15,
sortname: '0',
viewrecords: true,
gridview: true,
height: '100%',
autowidth: '100%'
});var reader = {
root: function(obj) { return results.rows; },
page: function(obj) { return results.page; },
total: function(obj) { return results.total; },
records: function(obj) { return results.records; },grid.setGridParam({data: results.rows, localReader: reader}).trigger('reloadGrid');

  

My "results" is an object like this:
{page: "1", total: "70", records: "1045", rows:[.....]}

  

jsonReader格式如下:
jQuery("#gridid").jqGrid({... jsonReader :{root: "rows",  //数据模型page: "page",//数据页码total: "total",//数据总页码records: "records",//数据总记录数repeatitems: true,//如果设为false,则jqGrid在解析json时,会根据name(colmodel 指定的name)来搜索对应的数据元素(即可以json中元素可以不按顺序)cell: "cell",//root 中row 行id: "id",//唯一标识userdata: "userdata",subgrid: {root:"rows", repeatitems: true, cell:"cell"}},... });示例json 数据格式; {"total": "xxx", "page": "yyy", "records": "zzz","rows" : [{"id" :"1", "cell" :["cell11", "cell12", "cell13"]},{"id" :"2", "cell":["cell21", "cell22", "cell23"]},... ]}

  

注意到加载json数据时

$(grid)[0].addJSONData(jsongrid);

是$(grid)[0]而不是$(grid)
推测[0]表示第一页,也就是数据全部加载到第一页了,但第一页数据数量受rowNum的限制

jqGrid获得所有行数据

var obj=$(“#tablename”).jqGrid(“getRowData”);

获取到的数据也是第一页的

建议解决办法:

1.使用后台返回的json数据,参考Web jquery表格组件 JQGrid 的使用 - 6.准备工作 & Hello JQGrid
url: "WebService/UserHandler.ashx",
datatype: "json",

 

2.自定义数据分页

 在onPaging事件里处理 参考Web jquery表格组件 JQGrid 的使用 – 4.JQGrid参数、ColModel API、事件及方法 事件

未尝试,感觉比较麻烦

3.数据量不是太大时,本地数据一般数据量不会太大

rowNum: 1000,
rowList: [1000],

  修改这两个不让翻页,改成拉滚动条吧

4.其他

欢迎高手给建议解决这个问题

 
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295