jQgrid subgrid - bad grid或cur是未定义的错误

时间:2012-10-09 13:14:06

标签: jquery json jqgrid subgrid

这是我正在努力解决这个问题的第二天,似乎没有人使用子网格,或者我在这里撒尿。

这是我的网格代码:

    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";
                });
            }
        },
    });

我已经调整了子网格URL以返回Json的几个差异,但这是我得到的最远:

{ “行”:[{ “细胞”: “0987654321”}]} Each character of the cell element works like a column

有人请帮助我。 @Oleg,看看你能不能。

1 个答案:

答案 0 :(得分:1)

我终于开始工作了。这是我做的:

我在subGridModel中添加了一个映射,如下所示:

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

并调整我的json bean以返回这样的内容:

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

这终于成功了。

Subgrid fixed