I am trying to customize the delete function in jqGrid.
I have enabled the delete button on the grid
$("#myGrid").jqGrid('navGrid', '#pager',
{ add: true, addtitle: 'Add Customer',
edit: true, edittitle: 'Edit Customer',
del: true, deltitle: 'Delete Customer',
refresh: true, refreshtitle: 'Refresh data',
search: true, searchtitle: 'Apply filters',
addfunc: addForo, editfunc: editForo,
cloneToTop: true
},
{}, // default settings for edit
{}, // default settings for add
{}, // default settings for delete
{ closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }, // search options
{} // default settings for view
);
then I have added (thanks to this post) the following code
$("#bDelete").click(function () {
// Get the currently selected row
toDelete = $("#myGrid").jqGrid('getGridParam', 'selrow');
$("#myGrid").jqGrid(
'delGridRow',
toDelete,
{ url: '/Foro/Delete/' + toDelete, mtype: 'post', reloadAfterSubmit: false }
);
});
Now when I click on the delete button a dialog is shown asking for delete confirm. But if I click on the delete button I will get the following error message

Where am I wrong?
If I understand you correct you want to modify the
urlused to delete of row so that the id of the row will be a part of theurl. You can do this much easier:With respect of
onclickSubmitwe can modify theurland defining ofserializeDelDatawe can clear the body of the “POST” message. I peronally mostly use RESTfull services on the server side and usemtype: "DELETE". In the case to clear of the body is really needed.One more option is to use
delfunclike you already useeditfuncandaddfunc. In the most cases the usage of such function is not really needed and one can implement the same in other way.