0

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"}]} Each character of the cell element works like a column

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

Paulo Pedroso
  • 3,555
  • 2
  • 29
  • 34
  • could you post a jsfiddle to show your issue? Is it an issue with it working at all or working in a specific set of conditions? – P6345uk Oct 09 '12 at 13:19
  • think your missing subGridRowExpanded - http://www.trirand.com/jqgridwiki/doku.php?id=wiki:subgrid_as_grid – P6345uk Oct 09 '12 at 13:22
  • Hi, I don't know what jsfiddle is. The problem was only with the subgrid, the grid is working fine. I am not using subgrid as grid but only subgrid. I am posting how I solved it. – Paulo Pedroso Oct 09 '12 at 20:49

1 Answers1

1

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.

Subgrid fixed

Paulo Pedroso
  • 3,555
  • 2
  • 29
  • 34