得到这个代码:
$('#hotels').jqGrid({
url : base_url + 'administrator/ajaxhotel',
datatype : 'json',
mtype : 'GET',
colNames : ['Hotel ID' , 'Hotel Name', 'Hotel Location','Type', 'Status', 'Active', 'Date Added'],
colModel : [
{name: 'id', index: 'id'},
{name: 'name', index : 'name', editable: true, editrules:{required:true, custom:true, custom_func: check_hotel_exists}, formatter: hotel_link_formatter, unformat:hotel_link_unformatter},
{name: 'location', index:'location'},
{name:'type', index:'type'},
{name: 'status', index: 'status', editable:true, edittype:'select', editoptions: {value: 'normal:Normal;sold:Sold'}},
{name: 'active', index: 'is_active', width: 100, resizable: false, editable:true, edittype:'select', editoptions:{value: '1:Active; 0:Not Active'}},
{name: 'date_added', index: 'date_added'},
],
cellEdit : true,
cellurl : base_url + 'administrator/ajaxhoteledit',
editurl : base_url + 'administrator/ajaxhoteledit',
afterSaveCell : showmessagecallback,
pager : '#pager',
emptyrecords: 'Nothing to display',
rowNum : 3,
rowList : [3, 5, 7],
sortname : 'name',
viewrecords : true,
caption : 'Hotel Listings',
autowidth: true,
multiselect : true,
errorCell : function(){
alert(triggered)
$('#message').text('An error has occurred while processing your request. Please check the manual for more information');
},
loadComplete : function(xhr){alert('loadComplete triggered')},
loadError : function(xhr, st, str){alert('loadError triggered');}
}).navGrid('#pager', {edit:false, add:false});
当删除失败时,即使我在 jqgrid 选项中设置了 loadError,也会出现模式对话框。我尝试在 loadError 函数中发出警报,结果发现该事件没有被触发。请帮忙!
最佳答案
loadError
仅适用于加载错误。编辑有自己的事件处理程序。例如,参见Form editing documentation 。在我看来,您想要 afterSubmit
。
或者,只处理 jQuery 的全局 ajaxError event 。我们这样做是为了集中整个应用程序的错误处理。
关于jquery - jqgrid 删除行时捕获服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1877992/