我正在将 treegrid 与 jqGrid 一起使用,并且对这个插件很陌生。我无法让 treegrid 功能正常工作。当我第一次单击展开按钮时,它工作正常。下一次,当我单击折叠时,它给了我 javascript 错误:
$t.p.data[pos] is undefined
这是在 jqGrid 的 setTreeNode 方法中。
我希望奥列格或有人能帮助或给我指点。
我的配置如下:
var grid = $("#grid").jqGrid({
treeGrid: true,
treeGridModel: 'adjacency',
ExpandColumn: 'businessAreaName',
ExpandColClick : true,
url:'agileProgramme/records.do',
datatype: 'json',
mtype: 'GET',
colNames:['Id'
, 'Business Area'
, 'Investment'
, 'Org'
, 'Goal'
],
colModel:[
/*00*/ {name:'agileProgrammeId',index:'agileProgrammeId', width:0, editable:false,hidden:true},
/*01*/ {name:'businessAreaName',index:'businessAreaName', width:160, editable:false},
/*02*/ {name:'programmeName',index:'programmeName', width:150, editable:false, classes:'link'},
/*03*/ {name:'org',index:'org', width:50, editable:false, classes:'orgHierarchy', sortable : false},
/*04*/ {name:'goal',index:'goal', width:70, editable:false}
],
treeReader : {
level_field: "level",
parent_id_field: "parent",
leaf_field: "leaf",
expanded_field: "expanded"
},
autowidth: true,
height: 240,
pager: '#pager',
sortname: 'id',
sortorder: "asc",
toolbar:[true,"top"],
caption:"TableGridDemo",
emptyrecords: "Empty records",
loadonce: true,
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "agileProgrammeId"
}
});
列展开时返回的数据如下。
{
"page":"1",
"total":"1",
"records":"1",
"rows":[
{
"agileProgrammeId":2,
"businessAreaName":"child",
"programmeName":"childSomething",
"goal":null,
"parent":1,
"level":"1",
"leaf":true,
"expanded":false
}
]
}
这是最初加载的数据。
{
"page":"1",
"total":"1",
"records":"1",
"rows":[
{
"agileProgrammeId":1,
"businessAreaName":"parent",
"programmeName":"parentsomething",
"goal":null,
"parent":null,
"level":"0",
"leaf":false,
"expanded":false
}
]
}