jquery - Why do my fields not populate with current value on JQGrid Inline Edit? -
i using jqgrid throughout application. on 2 screens inline edit, works fine. if field has value, puts value textbox when goes edit mode.
on 1 grid, not happening, , fields go blank when edit mode activated.
does know why happening?
the code bit much, i'll post if requests it. now, have thoughts why it's happening? thanks!
edit - code:
the defaults called first, init @ bottom kicks off rest. let me know if more needed.
here setdefaults call:
$.extend($.jgrid.defaults, { datatype: 'json', height: "100%", loadui: 'none', images: "/css/redmond/images/", jsonreader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: false, userdata: "userdata", id: "id" }, mtype: 'get', autowidth: true, rownum: 10, rowlist: [10, 20, 50, 100], viewrecords: true, loaderror: function (xhr, status, error) { alert('todo: implement error method - ' + error); }, beforerequest: function () { $("#load_grid").html('<h4 style="display: inline; position: relative; top: -10px; font-weight: bold">loading...</h4>' + $(".loader").html()); common.helpers.disablecontrols(); if (multi !== undefined && !multi) $("#grid").setgridparam({ multiselect: true }).showcol('cb'); }, gridcomplete: function () { if (!loadonce) { multi = false; common.grid.loadnavbar(); common.grid.initfilters(); $("th[id=grid_cb]") .css("text-align", "center") .css("position", "relative") .css("left", "1px"); } common.helpers.enablecontrols(); } });
here code called on page in question:
doubleclickrow: function (id) { if ($("#" + id).find("img[alt=loading]").length > 0) alert('please wait until row loaded before editing.'); else { var grid = $("#grid"); if (id && id !== lastsel) { grid.saverow(lastsel, true); $("#grid").setselection(id); lastsel = id; grid.editrow(id, true, function (row) { $("#" + row + "_storeqty").select(); }, null, null, null, { "detailid": $("#grid").getcell(id, "detailid") }, function (row) { // on success var rowid = row; var row = $("#" + rowid); var grid = $("#grid"); grid.setselection(row.next().attr("id")); row.next().focus(); store.cuts.index.doubleclickrow(row.next().attr("id")); }, null, null ); } } }, setupgrid: function (grid, pager) { common.grid.getcolumnmodel(); grid.jqgrid({ colnames: colnames, colmodel: colmodel, pager: pager, editurl: editurl, url: gridurl, pager: pager, height: 250, rownum: 20, ondblclickrow: store.cuts.index.doubleclickrow, onselectrow: function (id) { if (id && id !== lastsel) { grid.saverow(lastsel, true); } }, loadcomplete: function () { if (!loadonce) { loadonce = true; var ddlvendors = $(".ddl-vendors"); $(vendors).each(function () { ddlvendors.append('<option value="' + this.vendor + '">' + this.vendor + '-' + this.vendorname + '</option>'); }); $(".footer-row").show(); } if (grid.getgridparam("reccount") === 0) { $("#empty-grid-message").show(); } else { $("#empty-grid-message").hide(); } grid .setlabel('vendoritem', '', 'right') .setlabel('upc_display', '', 'right') .setlabel('casepack', '', 'right') .setlabel('retail', '', 'right') .setlabel('express', '', 'right') .setlabel('invqty', '', 'right') .setlabel('qty', '', 'right') .setlabel('storeqty', '', 'right'); grid.resetselection(); var rows = grid.getrowdata(); $(rows).each(function () { $.ajax( { url: pricingurl, data: "di_id=" + this["itemid"], success: function (result) { try { $("." + result.id + "_retail").html("").html(result.retail); $("." + result.id + "_sale").html("").html(result.saleamt); $("." + result.id + "_inventory").html("").html(result.invqty); } catch (ex) { $(".ajax").html(result); } } }); }); } }); }, init: function () { $.when(store.cuts.index.getpagedata()) .then(function () { store.cuts.index.setupgrid($("#grid"), $("#pager")); common.grid.initgridedit($("#grid"), store.cuts.index.doubleclickrow); $(".ddl-vendors").change(function () { extendedsearch.push({ name: "vendor", value: $(".ddl-vendors").val() }); common.grid.filtergrid(); }); $("#filter-div-btn-clear").click(function () { $(".ddl-vendors").val("-1") extendedsearch.push({ name: "vendor", value: "-1" }); }); }); }
here colmodel:
[{"id":0,"display_order":0,"header":"itemid","name":"itemid","index":"itemid","width":1,"align":"left","search":false,"editable":false,"hidden":true,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"detailid","name":"detailid","index":"detailid","width":1,"align":"left","search":false,"editable":true,"hidden":true,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"ship date","name":"shipdatedisplay","index":"shipdatedisplay","width":75,"align":"left","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"twodates","bydescr":""}, {"id":0,"display_order":0,"header":"item","name":"vendoritem","index":"vendoritem","width":50,"align":"right","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"upc","name":"upc_display","index":"upc_display","width":130,"align":"right","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"description","name":"itemdescription","index":"itemdescription","width":200,"align":"left","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"pack","name":"casepack","index":"casepack","width":35,"align":"right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"ret","name":"retail","index":"retail","width":50,"align":"right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"exp","name":"express","index":"express","width":50,"align":"right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"inv","name":"invqty","index":"invqty","width":30,"align":"right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"memo","name":"memo","index":"memo","width":50,"align":"left","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"distro","name":"qty","index":"qty","width":50,"align":"right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"request","name":"storeqty","index":"storeqty","width":60,"align":"right","search":false,"editable":true,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""}, {"id":0,"display_order":0,"header":"reason","name":"storereason","index":"storereason","width":160,"align":"left","search":false,"editable":true,"hidden":false,"editurl":"","edittype":"select","editoptions":{"_value":"reasons ","value":"1:no display/running;0:overstock"},"surl":"","bytype":"text","bydescr":""}]
ok, figured out.
in server side object colmodel, if editoptions blank, send down following:
editoptions":{"_value":" ","value":""}
this cause blank value when edit mode invoked. solve this, send null instead of blank, , if editoptions null, remove colmodel object.
$(colmodel).each(function () { if (this.editoptions === null) delete this.editoptions; });
Comments
Post a Comment