【问题标题】:jqgrid treegrid cant collapsing and expandingjqgrid treegrid不能折叠和展开
【发布时间】:2013-05-20 14:21:59
【问题描述】:

谁能向我解释我可能做错了什么?

我的树形网格是:

var grid = $("#account");
        jQuery(function($){
        grid.jqGrid({
            url: 'someurl',
            datatype: 'json', 
            height: 'auto', 
            mtype: 'post',
            colNames: ['Account Code','Account Name','Description','Account Type', 'Used By','Parent', 'Analysis 1', 'Analysis 2'],
            colModel: [
                {name:'szAccCode', index:'szAccCode', sortable:true, editable:true, editoptions:{readonly:'readonly'}},
                {name:'szAccNm',index:'szAccNm',width:200, editable:true},
                {name:'szAccNickNm',index:'szAccNickNm',width:250, editable:true},
                {name:'szAccTypeNm',index:'szAccTypeNm',edittype:"select",editable:true,editoptions:{value:"<?php echo $stracctype; ?>"},editrules:{required:true}},
                {name:'szUsedBy',index:'szUsedBy', width:100, editable:true},
                {name:'szAccParentCode',index:'szAccParentCode', hidden:true},
                {name:'szAccAnalysis_1',index:'szAccAnalysis_1', width:120, editable:true,edittype:"select",editoptions:{value:"<?php echo $straccanalys1; ?>"},editrules:{required:true} },
                {name:'szAccAnalysis_2',index:'szAccAnalysis_2', width:120, editable:true,edittype:"select",editoptions:{value:"<?php echo $straccanalys2; ?>"},editrules:{required:true} }

            ],
            rowNum: 20,
            rowList: [20,40,60],
            gridview: true,
            viewrecords: true,
            treeGrid: true,
            treeGridModel: 'adjacency',
            treedatatype: 'local',
            ExpandColumn: 'szAccCode',
            ExpandColClick: true,
            pager: '#accountPager',
            sortname: 'szAccCode',
            sortorder:'asc',
            caption: "Accounts", //Caption List                 
        });
        grid.jqGrid('navGrid','#accountPager',{edit:true,add:true,del:false, search:false});

而我的 json 数据是

{"page":"1","total":1,"records":"276","rows":[ ... ,{"id":"6","cell":["300-0-000","Hutang Lancar","Hutang Lancar","Hutang Lancar banget","Select One","","HSS: Information system ","Technical Assistance","0","null","false","true","true"]},
{"id":"7","cell":["310-0-000","Cash Advance Activity","Cash Advance Activity","Aktiva Tetap","Select One","300-0-000","HSS: Information system ","Technical Assistance","1","300-0-000","false","true","true"]},
{"id":"8","cell":["311-0-000","Cash Advance Operational","Cash Advance Operational","Aktiva Tetap","Select One","310-0-000","HSS: Information system ","Technical Assistance","2","310-0-000","true","true","true"]},
{"id":"9","cell":["320-0-000","Cash Advance Travel on Duty","Cash Advance Travel on Duty","Aktiva Tetap","Select One","300-0-000","HSS: Information system ","Technical Assistance","1","300-0-000","false","true","true"]}, ....}

它显示扩展的网格,不能折叠...

非常感谢您的帮助

TIA

【问题讨论】:

    标签: json jqgrid expand collapse treegrid


    【解决方案1】:

    您为"parent" 列使用了错误的数据。它应该包含父节点的id,但您使用szAccCode。您使用 "300-0-000" 和 310-0-000" 之类的值,而不是 "6" 和 "7"。

    【讨论】:

    • 谢谢它的工作原理.. 但我仍然有排序问题,孩子不在应该在的行中.. 但是当我点击任何列标题时,它排序完美。
    • @aramadhani:不客气!我认为您应该在开始时加载已排序的项目(在服务器端排序)。
    猜你喜欢
    • 1970-01-01
    • 2012-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-18
    • 2012-08-31
    • 2018-12-13
    相关资源
    最近更新 更多