tags:

views:

766

answers:

1

got this code:

$('#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});

When a deletion fails a modal dialog appears even if I have loadError set in the jqgrid options. I tried an alert in the loadError function and it turns out the event is no triggered. Please help!

+3  A: 

loadError is for loading errors only. Editing has its own event handlers. See, for example, the Form editing documentation. Looks to me like you want afterSubmit.

Alternatively, just handle jQuery's global ajaxError event. We do that to centralize error handling for the whole app.

Craig Stuntz