JQGrid没有改变页面(JQGrid not changing page)

编程入门 行业动态 更新时间:2024-10-26 09:19:35
JQGrid没有改变页面(JQGrid not changing page)

我在我的jqgrid表中有一个问题:我加载了json,我有我的表但我只能看到表的最后一页,没有更改页面的可能性。

js代码:

$("#list").jqGrid( { url:'test.json', datatype: "json", mtype: 'GET', colNames:['id','model','cc','nation','prod'], colModel:[ {name:'id', index:'id', jsonmap:"id", width:25}, {name:'model', index:'model', jsonmap:"model", width:50}, {name:'cc', index:'cc', jsonmap:"cc", width:25}, {name:'nation', index:'nation', jsonmap:"nation", width:50}, {name:'prod', index:'prod', jsonmap:"prod", width:50} ], rowNum: "2", page: "1", rowList: [2,4,6], autowidth: true, pager: '#pager', height: "100%", sortname: 'id', caption: "Elenco delle Moto", jsonReader: {root: 'rows',page: 'page',total: 'total',records: 'records',repeatitems: false,id: 'id'}, loadComplete: function() { grid.setGridHeight('auto'); } }); $("#list").jqGrid('navGrid','#pager',{edit:false,add:false,del:false,search:false}); $("#visual").hide();

和我的json文件:

{ "total": "3", "page": "1", "records": "5", "rows": [ { "Id": "1", "model": "shiver", "cc": "750", "nation": "italy", "prod": "aprilia" }, { "Id": "2", "model": "monster", "cc": "696", "nation": "italy", "prod": "ducati" } ], "page":"2", "rows": [ { "Id": "3", "model": "z750", "cc": "750", "nation": "japan", "prod": "kawasaki" }, { "Id": "4", "model": "hornet", "cc": "700", "nation": "japan", "prod": "honda" } ], "page":"3", "rows": [ { "Id": "5", "model": "speedtriple", "cc": "1000", "nation": "england", "prod": "buell" } ]

}

我已经尝试了很多次,但总是一样的结果..有人能帮帮我吗?

i have a problem in my jqgrid table: i load the json, i have my table but i can only see the last page of the table, without the possibility of changing the page.

the js code:

$("#list").jqGrid( { url:'test.json', datatype: "json", mtype: 'GET', colNames:['id','model','cc','nation','prod'], colModel:[ {name:'id', index:'id', jsonmap:"id", width:25}, {name:'model', index:'model', jsonmap:"model", width:50}, {name:'cc', index:'cc', jsonmap:"cc", width:25}, {name:'nation', index:'nation', jsonmap:"nation", width:50}, {name:'prod', index:'prod', jsonmap:"prod", width:50} ], rowNum: "2", page: "1", rowList: [2,4,6], autowidth: true, pager: '#pager', height: "100%", sortname: 'id', caption: "Elenco delle Moto", jsonReader: {root: 'rows',page: 'page',total: 'total',records: 'records',repeatitems: false,id: 'id'}, loadComplete: function() { grid.setGridHeight('auto'); } }); $("#list").jqGrid('navGrid','#pager',{edit:false,add:false,del:false,search:false}); $("#visual").hide();

and my json file:

{ "total": "3", "page": "1", "records": "5", "rows": [ { "Id": "1", "model": "shiver", "cc": "750", "nation": "italy", "prod": "aprilia" }, { "Id": "2", "model": "monster", "cc": "696", "nation": "italy", "prod": "ducati" } ], "page":"2", "rows": [ { "Id": "3", "model": "z750", "cc": "750", "nation": "japan", "prod": "kawasaki" }, { "Id": "4", "model": "hornet", "cc": "700", "nation": "japan", "prod": "honda" } ], "page":"3", "rows": [ { "Id": "5", "model": "speedtriple", "cc": "1000", "nation": "england", "prod": "buell" } ]

}

I've tried many times, but always the same result.. Can someone help me?

最满意答案

您的响应应该一次只包含一个页面(正确的page值说明哪个页面是这个),因此第一页的JSON应如下所示:

{ "total": "3", "page": "1", "records": "5", "rows": [ { "Id": "1", "model": "shiver", "cc": "750", "nation": "italy", "prod": "aprilia" }, { "Id": "2", "model": "monster", "cc": "696", "nation": "italy", "prod": "ducati" } ] }

jqGrid会进一步请求下一页,你应该检查请求的page和rows参数。 第一个将告诉您应该发回哪个页面,第二个将告诉您当前页面大小是多少(这很重要,因为您使用了rowList选项,因此可以更改页面大小)。

Your response should contain only one page at once (with the proper page value saying which page is this), so the JSON for first page should look like this:

{ "total": "3", "page": "1", "records": "5", "rows": [ { "Id": "1", "model": "shiver", "cc": "750", "nation": "italy", "prod": "aprilia" }, { "Id": "2", "model": "monster", "cc": "696", "nation": "italy", "prod": "ducati" } ] }

jqGrid will make further request for next pages, you should inspect page and rows parameters of the request. The first will tell you which page you should send back and the second will tell what is the current page size (this is important because you have used rowList option, so the page size can be changed).

更多推荐

本文发布于:2023-08-03 08:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1385236.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   JQGrid   page   changing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!