How to pass additional POST key to add controller if row is added using Add navigator button?
I tried code below to pass _dokdata with form values but _dokdata is not passed to controller in server.
$("#grid").jqGrid('inlineNav', '#grid_toppager', {
addParams: {
useDefValues : true,
useFormatter : false,
addRowParams : {
extraparam : { _dokdata : FormData },
editData: { _dokdata: FormData },
},
editData: { _dokdata: FormData },
extraparam : { _dokdata : FormData },
},
add: true,
edit: false,
save: true,
cancel: true,
editParams : {}
});
function FormData() {
return JSON.stringify($("#_form").serializeArray());
}
It seems that the problem which you describe is the mix from small error in your code and the bug in the code of jqGrid (see lines starting with the place).
The problem in your code is that you don't set
editParams
correctly like you do as foraddParams
. The correct usage should be:The problem in the current version of the code of jqGrid is in my opinion that jqGrid use in the Save button (see here) only the setting of
editParams.extraparam
are used instead of the usage of something likeaddParams.addRowParams.extraparam
. I addedkeys: true
option in theaddParams.addRowParams
parameters ofinlineNav
. So you will see that the current implementation (v 4.3.0) of the jqGrid will useaddParams.addRowParams.extraparam
if the user will save the changes by pressing of Enter and will useeditParams.extraparam
in case of saving the row by "Save" button of the navigator buttons.UPDATED: I tested the code and found one more bug in jqGrid v. 4.3.0. I suggested in the feature request to introduce
$.jgrid.inlineEdit
setting which can be used like other very practical setting$.jgrid.edit
but in case of inline and not form editing. The feature request is implemented in jqGrid 4.3.0, but the implementation contains a bug.To fix the bug one should replace the lines 33, 117 and 304 from
to
How you can see from the demo, all work correctly after the bug fixing.
UPDATED 2: The above fix is identical to the fix which is still incorrect. To fix the bug one have to make more changes in the code. For example the lines 32-36 (inside of
editRow
) can be changed fromto for example the following
In the same way the lines 116-120 (inside of
saveRow
)can be changed to
and the line 304
can be changed to
UPDATED 3: I posted my suggestion to trirand about the "Delete" problem. See the same demo which uses the fix here.