【发布时间】:2014-11-21 10:59:59
【问题描述】:
我正在使用jqgrid,当删除网格中的一行时,我收到警报“Delete selected record?”,当我点击确定时,我在onClickSubmit 中编写了一个代码来调用ajax控制器接受一些参数并删除记录。该功能运行良好。
但是当我单击警报中的“Delete”按钮时,我收到错误“No url is set”。现在,我的ajax 调用中有一个url,它执行该功能。为什么会抛出错误?
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);
}
});
当我在删除方法中提供一些我不需要的虚拟 url 时,它可以工作。我需要另一种方法来解决这个问题。?
仅供参考,这也发生在我使用form editing 编辑行期间。
【问题讨论】:
标签: asp.net-mvc jqgrid