I have a jqgrid with inline editing with custom buttons, I'm trying to show a custom message or popup if the save was unsuccesul:
editurl: '@Url.Action("UpdateMatrixData")',
datatype: "json",
postData: {
sp: function () { return getFilter(); }
},
postData: {
StartDate: function () { return $("#StartDate").val(); },
EndDate: function () { return $('#EndDate').val(); },
},
gridComplete: function ()
{
var ids = jQuery("#evGrid").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++)
{
var cl = ids[i];
be = "<input style='height:15px;width:15px;' title='Edit selected row' type='button' class='EditGridButton' onclick=\"jQuery('#evGrid').editRow('" + cl + "');\" />"
se = "<input style='height:15px;width:15px;' title='Save row' type='button' class='SaveButton' onclick=\"jQuery('#evGrid').saveRow('" + cl + "', '', '', '', reload());\" />" // dont Need to refesh grid after saving row - call reload function
ce = "<input style='height:15px;width:15px;' title='Cancel row editing' type='button' class='CancelButton' onclick=\"jQuery('#evGrid').restoreRow('" + cl + "');\" />";
jQuery("#evGrid").jqGrid('setRowData', ids[i], { act: be + se + ce });
}
},
function reload(rowid, response) {
alert(response)
$(this).jqGrid('setGridParam', { datatype: 'json' });
$(this).trigger('reloadGrid', [{ page: 1 }]);
}
the response is null however? and its being called before the updateMatrixData method gets called?
updateMatrixData returns Json(true) or Json(false)
return Json(isSucess);
Your main error in the usage of
onclick=\"jQuery('#evGrid').saveRow('" + cl + "', '', '', '', reload());\"
instead of
onclick=\"jQuery('#evGrid').saveRow('" + cl + "', '', '', '', reload);\"
reload
is callback function which will be called by jqGrid. If you use reload()
, then your code calls reload
mit empty parameters, before jqGrid do that (jqGrid don't get the reference of the function at all and get undefined
returned from reload()
instead).