简体   繁体   中英

jQgrid subgrid - bad grid or cur is undefined error

This is the second day I am struggling with this issue, it seems either no one is using subgrid or I am peeweeing something here.

This is my grid code:

    jQuery("#gridTable").jqGrid({ 
        url: ROOT + '/admin/station/getPagedList.json',
        datatype: "json", 
        jsonReader : {
            cell: "",
            id: "0", 
            repeatitems: false,
    //      subgrid: { 
    //           root:"rows", 
    //           repeatitems: false, 
    //           cell:"cell" 
    //        } 
            },
        colNames:['ID', 'Estação', 'Sigla', 'Linha', 'Lote', 'Empresa'], 
        colModel:[ 
                  {name:'id',index:'id', width:50, editable:false, hidden: true}, 
                  {name:'name',index:'name', width:130, editable:true}, 
                  {name:'acronym',index:'acronym', width:35, editable:true}, 
                  {name:'line.name',index:'line.name', width:130, editable:true}, 
                  {name:'line.lot.name',index:'line.lot.name', width:130, editable:false}, 
                  {name:'line.lot.company.name',index:'line.lot.company.name', width:130, editable:false}, 
        ], 
        subGrid : true,
        subGridUrl: ROOT + '/admin/contact/getList.json',
        subGridModel: [{
            name : ['Nome','Contato'],
            width : [150, 150] 
        }],
        rowNum:30, 
        rowList:[30,50,75], 
        pager: '#pager', 
        sortname: 'name', 
        viewrecords: true, 
        imgpath: ROOT + '/css/jquery/cptm/images',
        caption:'Estações', 
        height:"auto",
        altRows:true,
        altclass:"jqgrow-alt",
        loadError : function(xhr,st,err) {
            if (xhr.status.toString() == '901') {
                jAlert('Sua sess&atilde;o expirou.<br>Por favor efetue o login novamente.', 'AVISO', function(){
                    location.href = ROOT + "/logout";
                });
            }
        },
    });

I have already tweaked the subgrid URL to return several variances of Json but this is the most far I got:

{"rows":[{"cell":"0987654321"}]} 单元格元素的每个字符都像一列

Someone please help me. @Oleg, take a look if you can please.

I finally got it working. Here is what I did:

I added a mapping in the subGridModel as follows:

subGridModel: [{
    name : ['Nome','Contato'],
    mapping : ['name','contact'],
    width : [200, 200],
}], 

and tweaked my json bean to return something like this:

{"rows":[{"name":"Segurança de plataforma","contact":"0987654321"}]}

This finally did the trick.

子网格固定

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM