参考文章:http://stackoverflow.com/questions/5537728/jqgrid-pager-not-working-with-local-datatype
这个人的解答写的很好,只需要这么写
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');数据
{page: "1", total: "70", records: "1045", rows:[.....]}参考这个人的解答,发现
只要这么写就行了
把我门的jsonReader 改成localReader.代码如下
localReader:{
//id: "id",//设置返回参数中,表格ID的名字为blackId
rows:function(object){ return mydata[0].rows},
page:function(object){ return mydata[0].page},
total:function(object){ return mydata[0].total},
records:function(object){ return mydata[0].records},
repeatitems : false
}
本文详细介绍了如何在jqGrid中使用本地数据类型(local datatype)来展示数据,通过实例展示了如何将JSON数据转换为jqGrid所需的格式,并通过调整参数实现表格的动态更新。适用于前端开发人员,特别是使用jqGrid进行数据展示时需要了解的数据类型配置。
358

被折叠的 条评论
为什么被折叠?



