【问题标题】:jqGrid not displaying a single rowjqGrid不显示单行
【发布时间】:2011-04-16 20:03:33
【问题描述】:

我们的 jqGrid 运行良好 - 如果我们返回 > 1 行,一切正常。

但是.. 如果我们只返回一行,网格不会显示任何数据,并且导航栏会显示 NaN 的 1。很奇怪 - 有什么想法吗??

这是为单行返回的 JSON:

{"records":"1","page":"1","total":"1","rows":{"cell":["ECS","D","201009","","0","ABCD","0","0","","201009"],"id":"692334"}}

两行:

{"records":"2","page":"1","total":"1","rows":[{"cell":["BJL","F","201008","","0","ABCD","0","0","","201008"],"id":"724588"},{"cell":["BJL","F","201008","","0","ABCD","15","10","","201008"],"id":"728676"}]}

要加载/重新加载我们拥有的网格:

function reloadGrid(u, grid) {
  if (u!= null) {
      grid.setGridParam({url:u});
  }

  grid.setGridParam({page:'1', datatype:'json', loadonce:'true'}); 
  grid.trigger("reloadGrid");
}

还有网格本身:

$("#list").jqGrid({
url:'NoData.json',
datatype: 'json',
mtype: 'GET',
colNames:['Product', 'Type','Expiry', 'Put Call', 'Strike', 'Account','Long','Short', 'Open Qty', 'LTD', 'Operations'],
colModel :[
  {name:'product', index:'product', width:75},
  {name:'type', index:'type', width:50, align:'right'},
  {name:'expiry', index:'expiry', width:60, align:'right'},
  {name:'putCall', index:'putCall', width:65},
  {name:'strike', index:'strike', sorttype: 'float', width:70},
  {name:'account', index:'account', width:70},
  {name:'long', index:'long', sorttype: 'int', width:55, align:'right'},
  {name:'short', index:'short', sorttype: 'int', width:55, align:'right'},
  {name: 'openQty', index:'openQty', width:80, align:'center', sortable:false, search:false, formatter:closeoutFormatter},
  {name:'LTD', index:'LTD', width:65, align:'right'},
  {index:'operations', width:105, title:false, search:false, align: 'center', formatter:opsFormatter, sortable:false}
],
pager: '#pager',
scrollOffset:0, //No scrollbar
rowNum:15,
width:'100%',
viewrecords: true ,
caption: 'Positions',
height: '360',
hidegrid: false //Don't show the expand/collapse button on the top right
}).navGrid("#pager",{edit:false,add:false,del:false,
beforeRefresh: function(){
    reloadPositionGrid();  //Required so that we go to the server and not reload local data
}
});

【问题讨论】:

  • JSON 看起来不错,您能否包含 2 行的 JSON 对象、用于设置 jqGrid 的 JS 或输出的 HTML。我用单行的 jqGrid 就好了
  • 我也遇到了同样的问题stackoverflow.com/questions/12702106/…

标签: jquery jqgrid nan


【解决方案1】:

好的,1 的 JSON 没有将行放在 ARRAY 中,它只是放在 OBJECT

1 行

{"":"", "rows":{"cell":["",""], "id": "111"}

2 行

{"":"", "rows":[{"cell":["",""], "id": "111"}, {"cell":["",""], "id": "222"}]}

第二个 JSON 块包含 [{},{}] 中的行

检查输出 JSON 的服务器端代码。

【讨论】:

  • 没问题,jqGrid 已经把我打死了好几次,而且总是很简单;)
猜你喜欢
  • 2012-09-24
  • 1970-01-01
  • 1970-01-01
  • 2012-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多