I use jqgrid
, and when I delete a row in the grid, I get a warning “ Delete selected record?
”, And when I click ok, I wrote code in onClickSubmit
to make an ajax
controller call that takes some parameters and deletes the record. Functionality is working fine.
But when I click the “ Delete
” button in the warning, I get the error message “ No url is set
”. Now I have a url
inside my ajax
call that performs this function. Why was the error reset?
jqGrid:
var selectedRowId = "125"; $("#AttachmentsGrid").jqGrid({ url: '@Url.Action("LoadTransactionAttachments", "Home")', postData: { 'transactionId': selectedRowId }, mtype: 'GET', datatype: 'json', jsonReader: { id: 'AttachmentId', repeatitems: false }, height: 'auto', hidegrid: false, rownumbers: true, autowidth: true, shrinkToFit: false, rowNum: 10, pager: '#AttachmentsPager', caption: "Attachments", colNames: ['AttachmentName'], colModel: [{ name: 'AttachmentName', index: 'AttachmentName', formatter: imageFormatter, unformat: imageUnFormatter }], beforeRequest: function () { responsive_jqgrid($(".jqGrid")); }, onSelectRow: function (id) { var statusId; attachmentId = id; var selectValues = jQuery('#AttachmentsGrid').jqGrid('getRowData', id); attachmentName = selectValues.AttachmentName; if (accessLevel.HasDeleteAttachmentAccess == true) $("#del_AttachmentsGrid").show(); else $("#del_AttachmentsGrid").hide(); }, loadComplete: function () { UnBlockUI(); } }); jQuery("#AttachmentsGrid").jqGrid('navGrid', '#AttachmentsPager', { edit: false, add: false, del: true, search: false, refresh: true, refreshtext: "" }, {}, {}, { // url: '@Url.Action("UpdateDummyData", "Home")', // Delete attachment event. onclickSubmit: function (response, postData) { $.ajax({ url: '@Url.Action("DeleteSelectedTransactionAttachment", "Home")', datatype: 'json', data: { 'attachmentId': JSON.stringify(postData), 'attachmentName': attachmentName, 'transactionId': selectedRowId }, type: 'POST', success: OnCompleteDeleteAttachments, error: function (xhr, status, error) { if (xhr.statusText == "Session TimeOut/UnAuthorized") { alert(xhr.statusText); window.location.href = '@Url.Action("LogOut", "Account")'; } else alert(xhr.responseText); } });
This works when I give some Dummy url in the delete method that I don't need. I need another way to solve this problem.
FYI . This also happens during line editing with form editing
.