0

在使用 jQuery jqgrid 的 treegrid 类型时呈现扩展列文本时遇到问题。这是我的树网格定义和服务器的响应,如果有人可以帮助我,我会很高兴?

提前致谢。

Javascript

menuGrid.jqGrid({
    url:'kullanici/loadMenu.ajax', 
    //enable TreeGrid
    treeGrid: true,
    //set TreeGrid model
    treeGridModel: 'adjacency', //'nested', //'adjacency',
    //set expand column
    ExpandColumn: 'Text',
    width: 550,
    datatype: 'json',
    viewrecords: true,
    loadonce: true,
    colNames: ['ID', 'Text'],
    colModel: [
        { name: 'id', index: 'id', width: 20, align: 'left', editable: false, key: true, sorttype:'int', hidden: false },
        { name: 'Text', index: 'menuName', width: 120, sortable: true, align: 'left' }
    ],
    jsonReader: { 
        repeatitems : false,
        id: 'id'
    },
    sortname: 'id',
    sortorder: 'asc',
    height: 200,
    sortable: true,
    enabletooltips: true,
    caption: 'Menü Ağacı'
});
menuGrid.jqGrid('navGrid','#paddtree');

来自服务器的 JSON 响应

{"rows":[{"expanded":true,"id":1,"isLeaf":false,"level":0,"loaded":true,"text":"Kullanici Islemleri"},{"expanded":false,"id":2,"isLeaf":true,"level":1,"loaded":true,"parent":1,"text":"Kullanici Ekle"},{"expanded":false,"id":3,"isLeaf":true,"level":1,"loaded":true,"parent":1,"text":"Kullanici Duzenle"},{"expanded":false,"id":4,"isLeaf":true,"level":1,"loaded":true,"parent":1,"text":"Kullanici Sil"},{"expanded":true,"id":5,"isLeaf":false,"level":0,"loaded":true,"text":"Fatura ??lemleri"},{"expanded":false,"id":6,"isLeaf":true,"level":1,"loaded":true,"parent":5,"text":"Fatura Goruntule"}],"records":6,"success":true}
4

2 回答 2

0

Your Json response must be as follows :

    {"rows":[
        {
        "id":1,
        "text":"Kullanici Islemleri"
        "level":0,
        "isLeaf":false,
        "parent" : "null" //If the row is at 0-lvl
        "expanded":true,
        "loaded":true,
        },
    ],"records":6,"success":true}

You have to respect the order of the grid cols.
First, your data cols, then, level,isLeaf, parent,expanded. I'm not sure about the loaded field, try with and without.

于 2012-07-05T08:48:21.067 回答
0

好的,我找到了解决方案,colNames并且colModel配置ExpandColumn应该匹配(区分大小写)。正如我上面所说,配置的顺序并不重要。

于 2012-07-05T12:41:52.643 回答