删除行时,jqgrid catch服务器错误

时间:2009-12-10 00:55:37

标签: 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函数中尝试了一个警报,结果发现事件没有被触发。请帮忙!

1 个答案:

答案 0 :(得分:8)

loadError仅用于加载错误。编辑有自己的事件处理程序。例如,请参阅Form editing documentation。在我看来,你想要afterSubmit

或者,只需处理jQuery的全局ajaxError event。我们这样做是为了集中整个应用程序的错误处理。