jqGrid 展示问题

zppiio 发布于 2016/03/25 13:47
阅读 278
收藏 0

@蓝水晶飞机 你好,想跟你请教个问题:

jgGrid treeGrid 加载完成后展示的是全部数据,模式展开,点击收缩的按钮会把子节点的数据在加到已有的数据下面,不是关掉子节点。

js

$(document).ready(function() {
    // $('<table id="treegrid2"></table>').appendTo('#topics');
    var lastsel;
    grid = jQuery("#treegrid2");
    grid.jqGrid({
        treeGrid: true,
        grid: grid,
        datatype: 'json',
        mtype: 'POST',
        //提交方式为POST形式 
        url: "paging",
     
        treeGridModel: 'adjacency',
     
        ExpandColumn: 'name',
        viewrecords: true,
      
        colNames: ["id", "name", "parentId", "level", "isLeaf"],
        colModel: [{
            name: "id",
            index: 'id',
            width: 200,
            hidden: false,
            key: true
        },
        {
            name: "name",
            index: 'name',
            editable: true,
            width: 250,
            resizable: false
        },
        {
            name: "parentId",
            index: 'parentId',
            editable: true,
            width: 250,
            resizable: false
        },
        {
            name: "level",
            index: 'level',
            editable: true,
            width: 250,
            resizable: false
        },
        {
            name: "isLeaf",
            index: 'isLeaf',
            editable: true,
            width: 250,
            resizable: false
        }],
        treeIcons: {
            leaf: 'ui-icon-document-b'
        },
        caption: "jqGrid Demos",
        pager: "false",
        sortname: 'id',
        sortorder: "desc",


        jsonReader: {
            //     root: "dataRows",    
            repeatitems: false
        },
        treeReader: {
            level_field: "level",
            parent_id_field: "parentId",
            leaf_field: "isLeaf"
            //     expanded_field: "expanded"  
        },
        rowNum: "-1",
        // 显示全部记录  
        shrinkToFit: false // 控制水平滚动条
    });
});

json格式如下

[{"id":2,"name":"影音","isParent":false,"isLeaf":true,"status":true,"sortOrder":0,"isSystem":true,"parentId":1,"children":null,"parent":{"id":1,"name":"众筹","isParent":true,"isLeaf":null,"status":true,"sortOrder":0,"isSystem":true,"parentId":null,"children":null,"parent":null,"level":0,"expanded":false,"loaded":false},"level":1,"expanded":false,"loaded":false},{"id":3,"name":"公益","isParent":false,"isLeaf":true,"status":true,"sortOrder":1,"isSystem":true,"parentId":1,"children":null,"parent":{"id":1,"name":"众筹","isParent":true,"isLeaf":null,"status":true,"sortOrder":0,"isSystem":true,"parentId":null,"children":null,"parent":null,"level":0,"expanded":false,"loaded":false},"level":1,"expanded":false,"loaded":false}]

[ { "id": 2,  "name": "影音",  "isParent": false,  "isLeaf": true,  "status": true,  "sortOrder": 0,  "isSystem": true,  "parentId": 1,  "children": null,  "parent": { "id": 1,  "name": "众筹",  "isParent": true,  "isLeaf": null,  "status": true,  "sortOrder": 0,  "isSystem": true,  "parentId": null,  "children": null,  "parent": null,  "level": 0,  "expanded": false,  "loaded": false }, "level": 1,  "expanded": false,  "loaded": false }, { "id": 3,  "name": "公益",  "isParent": false,  "isLeaf": true,  "status": true,  "sortOrder": 1,  "isSystem": true,  "parentId": 1,  "children": null,  "parent": { "id": 1,  "name": "众筹",  "isParent": true,  "isLeaf": null,  "status": true,  "sortOrder": 0,  "isSystem": true,  "parentId": null,  "children": null,  "parent": null,  "level": 0,  "expanded": false,  "loaded": false }, "level": 1,  "expanded": false,  "loaded": false } ]


加载中
返回顶部
顶部