jquery - jqgrid 删除行时捕获服务器错误

标签 jquery jqgrid

得到这个代码:

$('#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/

相关文章:

spring - 整合jqgrid、mybatis、spring mvc和postgresql

jquery - 在jqGrid中查找当前页码

javascript - 如何在 jqGrid footerData 中使用 colspan?

jquery - 在 Visual Studio 2010 中使用 Microsoft jQuery vsdoc 1.7.1 CDN 时出现错误

jquery - 为什么我的跨度文本没有改变?

Jquery - Onclick按钮触发类中的所有div

jqgrid - 如何在 jqGrid 中编辑或添加新行

javascript - jQuery:模板化数据

JavaScript - 查找并替换数组中的单词

jqgrid - 将 RowData 传递给 Jqgrid 中的 Custom_func