jqGrid不显示单行 [英] jqGrid not displaying a single row
本文介绍了jqGrid不显示单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们的jqGrid运行良好-如果返回> 1行,则一切正常.
Our jqGrid is working well - if we return > 1 row everything works.
但是..如果我们仅返回一行,则网格将不显示任何数据,并且导航栏显示NaN为1.很奇怪-有什么想法吗?
But.. if we return just one row, the grid does not display any data and the nav bar says 1 of NaN. Very weird - any ideas??
这是为单行返回的JSON:
This is the JSON being returned for the single row:
{"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"}]}
要加载/重新加载网格,我们需要:
To load/reload the grid we have:
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
}
});
推荐答案
确定1的JSON不会将行放入ARRAY
中,而只是将一个OBJECT
Ok the JSON for 1 is not putting the rows in an ARRAY
it is just putting one OBJECT
1行
{"":"", "rows":{"cell":["",""], "id": "111"}
2行
{"":"", "rows":[{"cell":["",""], "id": "111"}, {"cell":["",""], "id": "222"}]}
第二个JSON块具有[{},{}]
The second JSON block has the rows in [{},{}]
检查正在输出JSON的服务器端代码.
Check your server-side code that is outputting the JSON.
这篇关于jqGrid不显示单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文