我遇到了自动加载树网格的问题。目前我的结构只有两层深。
1
a
b
c
2
a
当我单击展开节点时,网格似乎再次添加了根节点的另一个实例,以及应该根据所选根节点显示的任何子节点。
1
1
a
b
c
下面是选择根节点之前的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<page>1</page>
<total>1</total>
<records>1</records>
<row>
<cell>1112</cell>
<cell>Parent 1</cell>
<cell>0</cell>
<cell>NULL</cell>
<cell>false</cell>
<cell>false</cell>
</row>
</rows>
下面是选择根节点后的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<page>1</page>
<total>1</total>
<records>1</records>
<row>
<cell>1112</cell>
<cell>Parent 1</cell>
<cell>0</cell>
<cell>NULL</cell>
<cell>false</cell>
<cell>false</cell>
</row>
<row>
<cell>5207</cell>
<cell>Child 1</cell>
<cell>1</cell>
<cell>1112</cell>
<cell>false</cell>
<cell>false</cell>
</row>
</rows>
另外,这是我的配置:
$(document).ready(function(){
$("#gReport").jqGrid({
treeGrid: true,
treeGridModel: 'adjacency',
ExpandColumn: 'company',
url: document.forms['frmReport'].elements['gaddr'].value,
datatype: 'xml',
mtype: 'GET',
colNames: ["ID", "Company"],
colModel: [
{name: 'id', index: 'id', width: 1, hidden: true, key: true},
{name: 'company', index: 'company', width: 40, hidden: false, sortable: true}
],
rowNum: -1,
width: 980,
height: 'auto',
pager: false,
caption: ''
}),
});
任何帮助将不胜感激。谢谢。-克里斯