Hi Tony,
I’ve tried to do a “Grid as Subgrid” editable, but I can make it work.
Maybe there is something that i miss when i manage id in subgrid?
Thanks for your help!
Cristina
jQuery(“#thegrid”).jqGrid({
url:’thegridphp.php?q=1′,
datatype: “json”,
height: 410,
colNames:,
colModel:[
{name:’id’,index:’id’, hidden:true,width:55},
{name:’name’,index:’name’, width:1200}
],
rowNum:20,
rowList:[20,40,60],
imgpath: ‘jqgrid/themes/coffe/images’,
pager: jQuery(‘#pthegrid’),
sortname: ‘name’,
viewrecords: true,
sortorder: “asc”,
multiselect: false,
subGrid: true,
subGridRowExpanded: function(subgrid_id, row_id) {
// we pass two parameters
// subgrid_id is a id of the div tag created whitin a table data
// the id of this elemenet is a combination of the “sg_” + id of the row
// the row_id is the id of the row
// If we wan to pass additinal parameters to the url we can use
// a method getRowData(row_id) – which returns associative array in type name-value
// here we can easy construct the flowing
var subgrid_table_id;
subgrid_table_id = subgrid_id+”_t”;
$(“#”+subgrid_id).html(“”);
jQuery(“#”+subgrid_table_id).jqGrid({
url:’thesubgridphp.php?day=&id=’+row_id+’&nd=’+new Date().getTime(),
datatype: “json”,
colNames:,
colModel:[
{name:’subname’,index:’subname’, width:100,editable:true}
],
rowheight: 410,
rowNum:20,
//rowList:[20,40,60],
//pager:jQuery(‘#pthesubgrid’),
imgpath:’jqgrid/themes/coffe/images’,
sortname: ‘subname’,
sortorder: “asc”,
viewrecords: true,
onSelectRow: function(id){
if(id && id!==lastsel){
jQuery(‘#thesubgrid’).restoreRow(lastsel);
jQuery(‘#thesubgrid’).editRow(id,true,jQuery(‘#thesubgrid’).saveRow(id));
lastsel=id;
}
},
editurl: “thesubgrid_server.php”
})
},
subGridRowColapsed: function(subgrid_id, row_id) {
// this function is called before removing the data
var subgrid_table_id;
subgrid_table_id = subgrid_id+”_t”;
jQuery(“#”+subgrid_table_id).GridDestroy();
}
});