設置我使用jqgrid
並在網格中的一行,當我得到警報「Delete selected record?
」當我點擊確定我已經寫在onClickSubmit
代碼做出ajax
調用控制器會接收一些參數並刪除記錄。該功能正常工作。刪除,任何URL中的jqGrid
但是,當我在警報中,單擊「Delete
」按鈕,我得到一個錯誤「No url is set
」。現在,我有一個url
我ajax
調用,它確實在函數內部。爲什麼會拋出錯誤?
的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);
}
});
它工作時,我給在刪除方法,我不需要一些虛擬的網址。我需要另一種方法來解決這個問題。
FYI,在使用form editing
編輯一行時,這也發生在我身上。
這是非常甜蜜。完美的工作。謝謝!!! – iamCR 2014-11-24 11:58:20
@SanthoshKumar:歡迎您! – Oleg 2014-11-24 12:17:10