我一直在试图让“Grid as Subgrid”功能工作,并没有得到太多的运气。我认为这是我在我的代码中做的错,因为它在独立测试中运行良好。但是,我终于注意到只有我的应用程序和我的测试页之间的区别是我的应用程序在IE7上运行,并且我正在Firefox中运行我的测试页。果然,当我在IE7中加载测试页时,我遇到了同样的问题。jqGrid有问题在IE7加载子网格
将瑞普在IE7的问题的代码如下:
$(function() {
function loadTasks(subgrid_id, row_id)
{
var id = subgrid_id + '_t';
$('#' + subgrid_id).html('<table id="' + id + '"></table>');
jQuery("#" + id).jqGrid({
datatype: 'local',
colNames: ['No','Item','Qty','Unit'],
colModel: [
{name:'num',index:'num',width:80,key:true},
{name:'item',index:'item',width:130},
{name:'qty',index:'qty',width:70,align:'right'},
{name:'unit',index:'unit',width:70,align:'right'}
],
height: '100%'
});
}
var x = $("#grid").jqGrid({
jsonReader: { root: "rows", repeatitems: false },
datatype: "json",
height: 'auto',
autowidth: true,
forceFit: true,
colNames:['ID','Name'],
colModel:[
{name:'id', key:true, index:'id', width:60, sorttype:"int", jsonmap:"id"},
{name:'name', index:'foobar', width:90, jsonmap: "name"}
],
subGrid: true,
subGridRowExpanded: loadTasks,
caption: "Results"
});
var jsonData = [
{id: 1, name: 'Apple'},
{id: 2, name: 'Banana'},
{id: 3, name: 'Pear'},
{id: 4, name: 'Orange'}
];
x[0].addJSONData({ rows: jsonData });
});
它似乎产生了对各行一些虚假的内容,不正确渲染的行内。下面是如何呈现在IE7抓屏:
有什么奇怪的是那些“不确定”的行实际上是有效的网格行的一部分,如果我将鼠标悬停在“苹果”,那么第一undefined行也亮点。
我选择jqGrid在其他网格上的主要原因是它支持嵌套多个网格(我们真的需要为我们的应用程序),但是我们的公司标准仍然是IE7,所以我们需要支持这个浏览器。有什么我可以做的,使这个功能在IE7下正常工作?
哦,太棒了!看起来这是几天前的字面上固定的..我想我必须自己挖掘这个代码。感谢您最近的jqGrid帮助,@ Oleg .. – 2012-04-24 16:45:36
@MikeChristensen:不客气!我很惊讶,但“新jqGrid 4.3.2”版本包含许多新功能(请参阅我的答案的“更新”部分)。 – Oleg 2012-04-24 17:00:09
是的,听起来像是有人忘记了编号。这会在错误报告中造成一些混淆! – 2012-04-24 17:12:04