0

I am trying to load the TreeGrid (jqGrid) with array data. But somehow hierarchy is not showing up. The data is only appearing in flat structure.

Code:

$("#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
});

then I add the rows in the array to the grid:

$('#list').jqGrid('addRowData',0,array[0]);
$('#list').jqGrid('addRowData',1,array[1]);

Structure of array:

array=[{parent:"",label:"1",cd:"32"},{parent:"1",label:"2",cd:"42"}]

can anyone help?

4

1 に答える 1

0

あなたの質問の答えはここにあります。

addRowDataこれは遅く、ほとんど間違って使用されるため、使用しないでください。親ノードにはparent: "null"またはを使用する必要がありますparent: null。さらに、TreeGrid の入力データにはlevel、 、isLeaf. loaded:trueすべてのノードは、ノードをローカルに保持する必要があります。

入力項目の正しい順序を使用することが重要です。順序は、完全に展開されたツリーの項目の順序に対応する必要があります。したがって、すべての子は親に従う必要があります。

colModelや などの不明なプロパティから削除する必要がidありvisibleます。ドキュメントにあるサポートされているプロパティのリスト。

于 2012-04-21T13:59:08.483 に答える