json jqgrid树grid无法折叠和展开

juzqafwq  于 2022-12-01  发布在  其他
关注(0)|答案(1)|浏览(179)

谁能给我解释一下我可能做错了什么?
我的树网格是:

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"]}, ....}

它显示为展开的网格,无法折叠...
我真的很感谢你的帮助
短暂性脑缺血

o2g1uqev

o2g1uqev1#

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

相关问题