Anuja Anuja - 4 months ago 36
jQuery Question

aftersavefunc is not work in inline JqGrid properly

I am working on jqgrid.in that inline jqgrid I want to display sum of column of jqGrid into another text box outside jqgrid.I am do some code for that. the code is below

$("#ItemGrid").jqGrid("inlineNav", "#nav-ItemGrid", {
edit: true,
add: true,
addicon: "ui-icon-plus",
save: true,
view: true,
cancel: false,
editParams: {
aftersavefunc: function () {
var colSum = $('#ItemGrid').jqGrid('getCol', 'Total', false, 'sum');
$('#TotalBeforeDiscount').val(colSum);
},
keys: true
},
addParams: {
position: 'last',
aftersavefunc: function () {
var colSum = $('#ItemGrid').jqGrid('getCol', 'Total', false, 'sum');
$('#TotalBeforeDiscount').val(colSum);
}, keys: true
}
});


this code is work only for editParams not for AddParams.But I can not understand why this is happen.Please give some suggestion.
Thanks in advance..........

Answer

You use addParams property of inlineNav in the wrond way. The options of inline editing like position: 'last' and aftersavefunc have to be inside of property addRowParams of addParams. See the answer for example for more details. If you use free jqGrid then I'd recommend you to use inlineEditing option of jqGrid to set default properties of inline editing. See the wiki article for more details.