Reputation: 3685
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ã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.
Upvotes: 0
Views: 723
Reputation: 3685
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.
Upvotes: 1