【问题标题】:JqGrid with subgrid and local data not working in IE9 - throws - "SCRIPT600: Invalid target element for this operation"带有子网格和本地数据的 JqGrid 在 IE9 中不起作用 - 抛出 - “SCRIPT600:此操作的目标元素无效”
【发布时间】:2015-04-17 00:02:35
【问题描述】:

我是 JQGRID 的新手,我使用的是 4.7.1 版。

我正在尝试使用 SUBGRID 创建 JQGRID。该代码在 Google chrome 中按预期工作,但在 IE9 中出现以下错误。

SCRIPT600: Invalid target element for this operation. 
jquery.jqGrid.src.js, line 1639 character 6

如何解决该错误并使其在 IE9 中运行。请做必要的事。在此先感谢。

<html>
<head>
<title>My First Grid</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-    ui.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />




<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="js/jquery-ui.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.src.js" type="text/javascript"></script> 




<style>
.ui-jqgrid tr.ui-row-ltr td 
{ 
border-right-color: transparent;
height:auto;
overflow:hidden;    
padding-top:6px;
padding-bottom:6px;
position:relative;
vertical-align:text-top;
white-space:normal !important; 
}

th.ui-th-column { border-right-color: transparent !important }

.ui-jqgrid .ui-jqgrid-btable
{
table-layout:auto;
}

.top-buffer { margin-top:20px; }

.cursorPointer:hover{
cursor:pointer
}


.ui-jqgrid .ui-jqgrid-htable th div {
height:auto;
overflow:hidden;    
padding-top:6px;
padding-bottom:6px;
position:relative;
vertical-align:text-top;
white-space:normal !important;
}


</style>
</head>

<body>

<div >
<table id="grid"></table>
</div>


</body>


<script type="text/javascript">

var mydata = [
{id: "1", label:"No 1", number:"02200220", status:"OPEN", level:"0", parent:  "", isLeaf: false, expanded:false, loaded:true},
{id: "2", label:"No 2", number:"77733337", status:"ENTERED", level:"0", parent: "", isLeaf: false, expanded:false, loaded:true},
{id: "6", label:"No 2a", number:"12345123", status:"WIRED", level:"1", parent: "2", isLeaf: false, expanded:false, loaded:true},
{id: "7", label:"No 2a1", number:"1111111111", status:"WIRED", level:"2", parent: "6", isLeaf: true, expanded:false, loaded:true},
{id: "3", label:"No 3", number:"02200111", status:"OPEN", level:"0", parent: "", isLeaf: false},
{id: "4", label:"No 3a", number:"02200221", status:"OPEN", level:"1", parent: "3", isLeaf: true, expanded:false, loaded:true},
{id: "5", label:"No 3b", number:"02242320", status:"CLOSED", level:"1",   parent: "3", isLeaf: true, expanded:false, loaded:true}
];

var grid = $("#grid");


grid.jqGrid({
// data: mydata, // doesn't work
datatype: "local",
colNames: ['Id', 'Label', 'Number', 'Status'],
colModel: [
{ name:'id',index:'id', width:60, sortable:false},
{ name: 'label', index: 'label', width: 180, sortable:false},
{ name: 'number', index: 'number', width: 120, formatter: function    (cellValue, option, rowObject) 
{
        return "<span><img src='images/play.png'></img></span><span style='padding-left:10px'><img src='images/Download-icon.png'><span>";
    } },
{ name: 'status', index: 'status', width: 120, sortable:false } ],
hidegrid: false,
gridview: true,
sortname: 'id',    
loadonce: true,

treedatatype: 'local',
ExpandColumn: 'label',
height: 'auto',
pager : "#gridPager",
caption: "Prouct Page Table"
});


// we have to use addJSONData to load the data
grid[0].addJSONData({
total: 1,
page: 1,
records: mydata.length,
rows: mydata
});



</script>



</html>

【问题讨论】:

    标签: jqgrid subgrid


    【解决方案1】:

    TreeGrid 不适用于datatype: "local",但可以使用datatype: "jsonstring"。只需使用datastr: mydata 而不是data: mydata。对于顶级图标,您应该另外使用 parent: "null" 而不是 parent: ""。它允许额外进行本地排序。对应的代码示例见the answer

    问题“jquery.jqGrid.src.js, line 1639”的原因可能是使用firstElementChild的错误。有关详细信息,请参阅the answer。修复后可以从here下载jqGrid 4.7.0的jquery.jqGrid.src的代码。或者,您可以从my fork of jqGrid 下载新的免费 jqGrid 测试版。

    【讨论】:

      猜你喜欢
      • 2018-05-13
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      • 2012-09-17
      • 2011-05-25
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      相关资源
      最近更新 更多