jqGrid treetable:显示在父级上方的嵌套列

时间:2011-07-29 00:34:14

标签: jquery jqgrid

我正在使用jqGrid作为具有邻接数据类型的treetable(据我所知)。嵌套工作正常,但由于某种原因,子行显示在父级上方而不是在父级下方:

$(function() {

$("#features").jqGrid({
    height:'100%',
    sortname: 'name',
    treeGrid: true,
    loadonce: true,
    treeGridModel: 'adjacency',
    treedatatype: 'local',
    ExpandColumn: 'name',
    datatype: "local",
    colNames:["id","Name"],
    colModel:[
        {name:'id',index:'id', hidden:true,key:true},
        {name:'name',index:'name',width:200}
    ],
    jsonReader: {
        repeatitems: false,
        id: "id",
        root: function (obj) { return obj; },
        page: function (obj) { return 1; },
        total: function (obj) { return 1; },
        records: function (obj) { return obj.length; }
    }
 });
}

showSummaryTable(jQuery.parseJSON('[{"id":"1","name":"Here is a nested  row.","level":1,"isLeaf":true,"expanded":false,"parent":"0"},{"id":"0","name":"Parent","level":0,"isLeaf":false,"expanded":false,"parent":""}]'));
});

    function showSummaryTable(data) {
        var thegrid = $("#features");
        thegrid[0].addJSONData({
            total: 1,
            page: 1,
            records: data.length,
            rows: data
         });            
    }

这是我最终的结果:

jqgrid

1 个答案:

答案 0 :(得分:0)

事实证明,JSON中记录的顺序很重要。它们必须从最低级别(父级)到最高级别进行排序。一旦我对JSON进行了排序,我的问题就解决了。