tonytomov/jqGrid — comment on commit df5193e9c278247afb4d634b204f66242aedd55f
File:  line 0
By OlegKi:

Hello Tony,

The changes still not fix the bug. The first problem is that `settings` will be initialized before with `keys` properties set as **an object** in case of `editRow` or with `successfunc` initialized as **an object** instead of function in case of `saveRow`. The next problem is that the settings `$.jgrid.inlineEdit` will be overwrite by default values from the `settings`.

I described [here](http://stackoverflow.com/a/8551798/315935) possible changes which will fix there.

I think that probably it will be better to rewrite the code at the beginning of the `editRow`, `saveRow` and `restoreRow`. The variable `settings` will be used only at the initialization steps and the variable `o` can be initialized directly. Moreover the current code allows not only the call of for example `editRow` in the form

jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);

or in the form

jQuery("#grid_id").jqGrid('editRow',rowid, {keys: true, oneditfunc: myFunc});

but also in the form

jQuery("#grid_id").jqGrid('editRow',rowid, {keys: true, oneditfunc: myFunc}, myEditFunc2, mySuccesFunc);

which make the logic more complex. Probably it would be better **to ignore all other parameters if any exist** if the `key` parameter will be object? I mean that one should use really *empty* parameters in case of `typeof(args[0]) === "object"`. One can rewrite the first lines of the `editRow` for example to the following

var o;

if (typeof keys === "object" && !$.isFunction(keys)) {
o = $.extend(true, {
successfunc: null,
url: null,
extraparam: {},
aftersavefunc: null,
errorfunc: null,
afterrestorefunc: null,
restoreAfterError: true,
mtype: "POST"
}, $.jgrid.inlineEdit, keys);
} else {
o = {};
// don't set any default settings in o to prevent
// ovewriting of the corresponding settings of $.jgrid.inlineEdit
if (typeof keys !== "undefined") { o.keys = keys; }
if ($.isFunction(oneditfunc)) { o.oneditfunc = oneditfunc; }
if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
if (typeof url !== "undefined") { o.url = url; }
if (typeof extraparam !== "undefined") { o.extraparam = extraparam; }
if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
if (typeof restoreAfterError !== "undefined") { o.restoreAfterError = restoreAfterError; }
if (typeof mtype !== "undefined") { o.mtype = mtype || "POST"; }

o = $.extend(true, {
successfunc: null,
url: null,
extraparam: {},
aftersavefunc: null,
errorfunc: null,
afterrestorefunc: null,
restoreAfterError: true,
mtype: "POST"
}, $.jgrid.inlineEdit, o);
}

Best regards
Oleg