It looks as if this question has been asked at least once before but was not answered. I have also seen this question answered regarding standard "form" based editing, but not inline.
Code
$(function() {
var lastSel;
var MSVendors = {'9990':'XXXXXX - LEXI','9991':'XXXXXX - RICH','9992':'XXXXXX - BIRM','9993':'XXXXXX - PEMB' };
$('#special_dialog').dialog({
width:'auto',
height:'auto',
resizable:true
});
$.extend($.jgrid.defaults,{
rowNum:250,
rowList:[1000,2500,5000],
viewrecords:true,
sortorder:'asc',
height:800,
autowidth:true,
deepempty:true,
altRows: true,
grouping: true,
groupingView: {
groupField: ["vendor"],
groupColumnShow: [true],
groupText: ["<b>WAREHOUSE : {0}</b>"],
groupDataSorted: true,
groupSummary: [false]
}
});
var surplusGrid = $('#surplusGrid'),
editingRowId,
sEditParam = {
keys: true,
oneditfunc: function(id) {
editingRowId = id;
$('#surplusGrid_ilsave').removeClass('ui-state-disabled');
$('#surplusGrid_ilcancel').removeClass('ui-state-disabled');
},
afterrestorefunc: function() {
editingRowId = undefined;
}
},
sAutoCompOpts = {
source: function(request, response) {
$.getJSON('/json/json.searchmultiMaterials.php',{term:request.term,type:'m'},function(data) {
response(data);
});
},
minLength: 3,
focus: function(e,ui) {
$('input:text[name="description"]').val(ui.item.description);
$('input:text[name="vendor"]').val(ui.item.vendor);
$('input:text[name="mfgr_partno"]').val(ui.item.mfgr_partno);
},
select: function(e,ui) {
$('input:text[name="description"]').val(ui.item.description);
$('input:text[name="vendor"]').val(ui.item.vendor);
$('input:text[name="mfgr_partno"]').val(ui.item.mfgr_partno);
}
},
sAddParam = {
rowID: 'new',
position:'last'
};
surplusGrid.jqGrid({
url: '/json/json.getSurplusStock.php',
datatype:'json',
emptyrecords: 'Surplus Stock is currently depleted!',
colNames: ['ID','Type','Part#','Description','On-Hand','On-Order','On-Hold','Min Stock','Warehouse','Shelf','Bin'],
colModel: [
{ name:'id',
index:'id',
hidden:true,
key:false,
search:false,
viewable:false
},
{ name:'type',
index:'type',
width:35,
sortable:true,
editable:false,
align:'center',
editoptions:{defaultValue:'B'},
cellattr: function(rowId,val) {
if (val == 'B') {
return 'class="blue_stock"';
} else {
return 'class="gold_stock"';
}
}
},
{ name:'surplus_partno',
index:'surplus_partno',
width:140,
sortable:false,
editable:true,
classes:'ui-ellipsis',
edittype:'text',
editoptions:{size:25},
editrules:{required:true}
},
{ name:'description',
index:'description',
width:200,
sortable:false,
align:'left',
editable:true,
classes:'ui-ellipsis',
edittype:'text',
editoptions:{size:40},
editrules:{required:true}
},
{ name:'on_hand',
index:'on_hand',
width:60,
sortable:false,
editable:true,
align:'center',
edittype:'text',
editoptions:{size:6},
editrules:{required:true,integer:true,minValue:0}
},
{ name:'on_order',
index:'on_order',
width:60,
sortable:false,
editable:true,
align:'center',
edittype:'text',
editoptions:{size:6},
editrules:{required:false,integer:true,minValue:0}
},
{ name:'on_hold',
index:'on_hold',
width:60,
sortable:true,
editable:true,
align:'center',
edittype:'text',
editoptions:{size:6},
editrules:{required:true,integer:true}
},
{ name:'min_threshold',
index:'min_threshold',
width:60,
sortable:true,
editable:true,
align:'center',
edittype:'text',
editoptions:{size:6},
editrules:{required:true,integer:true,minValue:0}
},
{ name:'vendor',
index:'vendor',
width:120,
editable:true,
align:'center',
editoptions:{value:MSVendors},
edittype:'select',
editrules:{required:true,integer:true}
},
{ name:'shelf',
index:'shelf',
width:40,
sortable:true,
editable:true,
align:'center',
editoptions:{size:10}
},
{ name:'bin',
index:'bin',
width:40,
sortable:true,
editable:true,
align:'center',
editoptions:{size:10}
}
],
pager:'#surplusFoot',
sortname:'b.id',
caption:'Surplus Stock Inventory',
onSelectRow: function(id) {
if(id && id !== lastSel) {
surplusGrid.jqGrid('restoreRow',lastSel);
var cm = surplusGrid.jqGrid('getColProp','vendor');
if (id != 'new') { cm.editable = false; }
lastSel = id;
}
surplusGrid.jqGrid('editRow',id,true);
$('#surplusGrid_ilsave').removeClass('ui-state-disabled');
$('#surplusGrid_ilcancel').removeClass('ui-state-disabled');
},
editurl:'/jqg/jqg.saveSurplusStockEdit.php'
});
surplusGrid.jqGrid('navGrid','#surplusFoot',{
add:false,
edit:false,
del:false
});
surplusGrid.jqGrid('inlineNav','#surplusFoot',{
add:true,
edit:true,
editParams:sEditParam,
addParams:sAddParam
});
// re-size all grids when dialog box resizes
$('#special_dialog').dialog({
resizeStop: function(e,ui) {
surplusGrid.jqGrid('setGridWidth', ui.size.width - 30);
}
});
});
Works GREAT on inline ADD - dropdown appears and value is passed to the editing URL as expected. On inline EDIT, however, the entire dropdown vanishes, leaving a " " as the cell content rather than the value that was there when the grid initially loaded.