我正在尝试使用数组数据加载 TreeGrid (jqGrid)。但不知何故,等级制度并没有出现。数据仅以扁平结构出现。
代码:
$("#list").jqGrid({
treeGrid: true,
treeGridModel: 'adjacency',
ExpandColumn: 'label',
ExpandColClick: true,
datatype: 'local',
colNames:['Parent','Org','cd'],
colModel:[
{name:'parent',id:'parent',index:'parent', width:250, hidden: true,
align: 'left', sortable: false, classes: 'indeling', title: false },
{name:'label',id:'label',index:'label', width:250,align: 'left',
sortable: false, classes: 'indeling', title: false, visible: false},
{name:'cd',id:'cd',index:'cd', width:100,align: 'left', sortable: false,
classes: 'indeling', title: false,visible: false }
],
rowNum: 20000,
viewrecords: true,
height: "100%",
treeIcons: { leaf: 'ui-icon-document-b' },
hoverrows: false
});
然后我将数组中的行添加到网格中:
$('#list').jqGrid('addRowData',0,array[0]);
$('#list').jqGrid('addRowData',1,array[1]);
数组结构:
array=[{parent:"",label:"1",cd:"32"},{parent:"1",label:"2",cd:"42"}]
谁能帮忙?