title: how to show error message on delete in jqgrid?
body: <p>hiii to all, i am using jqgrid, and want to display error message if the user wants to delete the truck record which is in use, i have to display a error message truck in use..
  here is my jqgrid:-</p>
  
  <pre><code>    jQuery(document).ready(function () {
  
  
          var grid = jQuery("#TrucksGrid141");
  
          grid.jqGrid({
              url: '/Admin/GetTrucksForJQGrid',
              datatype: 'json',
                  mtype: 'Post',
                   cellsubmit: 'remote',
                 cellurl: '/Admin/SaveTruck',
                 height: '100%',
                 pager: '#pagerTrucks',
  
              colNames: ['Id', 'Name', ''],
              colModel: [
              { name: 'Id', index: 'Id', key: true, hidden: true, editrules: { edithidden: true } },
              { name: 'Name', index: 'Name', align: "center", sorttype: 'text', resizable: true, editable: true, editrules: { required: true } },
  
  
              { name: 'Delete', index: 'Delete', width: 25, resizable: false, align: 'center', classes: 'not-editable-cell' }
  
              ],    
  
  
  
              width: '490',           
              caption: 'Company Trucks',
              hidegrid: false,
              delete: true,
              cellEdit: true,
              viewrecords: true,
              gridComplete: function () {
  
                  var ids = grid.jqGrid('getDataIDs');
                  for (var i = 0; i &lt; ids.length; i++) {
                      var isDeleted = grid.jqGrid('getCell', ids[i], 'Delete');
                      if (isDeleted != 'true') {
                          grid.jqGrid('setCell', ids[i], 'Delete', '&lt;a href="#" onclick="deleteRow(' + ids[i] + ');"&gt;&lt;img src="/Images/delete.png" alt="Delete Row" /&gt;&lt;/a&gt;');
                      }
                      else {
                          grid.jqGrid('setCell', ids[i], 'Delete', ' ');
                          //grid.jqGrid('setCell', ids[i], 'Privileges', 'admin');
                      }
                  }
              }
          }
  
          );
  
          grid.jqGrid('navGrid', '#pagerTrucks',
         { resize: false, add: false,search:false, del: false, refresh: false, edit: false, alerttext: 'Please select one user' }
  
     ).jqGrid('navButtonAdd', '#pagerTrucks',
         { title: "Add New Truck", buttonicon: "ui-icon ui-icon-plus", onClickButton: showNewTruckModal, position: "First", caption: "" });
  
      });
  
      function showNewTruckModal() {
  
          var grid = jQuery("#TrucksGrid141");
          $("#formAddNewTruck").dialog(
                  {
                      open: function (event, ui) {
  
                          $("#txtName").val('');
                          $("#trFormErrorTrucks").hide();
                          $("#trFormErrorTrucks td").text('');
  
                      },
                      buttons: {
                          "Submit": function () {
                              debugger;
                              if (ValidateUsers() == true) {
                                  $('#error').ajaxError(function (event, request, settings) {
                                      $('#waiting').hide();
                                      $(this).addClass('errordiv').text(request.statusText + "" + request.status);
  
                                  });
                                  $.post('/Admin/AddNewTruck/',
                                  $('#formAddNewTruck').serialize(),
                                  function (data) {
                                      debugger;
                                      if (data == 'Success') {
                                          $('#formAddNewTruck').dialog("close");
                                          grid.jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
                                      }
                                      else {
                                          $("#trFormErrorTrucks").show();
                                          $("#trFormErrorTrucks td").text(data);
                                      }
  
                                  });
                              }
                          },
                          "Cancel": function () {
                              $('#error').removeClass("errordiv").text("");
                              $('#waiting').hide();
                              $(this).dialog("close");
                          }
                      },
                      modal: true,
                      title: "New Truck",
                      minWidth: 400,
                      resizable: false
                  }
          ).dialog('open');
      }
  
      function ValidateUsers() {
              var flag = true;
              var errorMSG = '';
              $("#trFormErrorTrucks td").text('');
              if ($("#txtName").val() == '') {
                  errorMSG += 'Truck Name cannot be blank';
                  flag = false;
              }
  
  
              if (flag == false) {
                  $("#trFormErrorTrucks").show();
                  $("#trFormErrorTrucks td").text(errorMSG);
              }
              else {
                  $("#trFormErrorTrucks td").text('');
                  $("#trFormErrorTrucks").hide();
              }
              return flag;
          }
  
      function deleteRow(rowid) {
          jQuery("#TrucksGrid141").delGridRow(rowid, { url: '/Admin/TruckDelete', caption: 'Delete User?', msg: 'Delete selected User? &lt;br /&gt;Careful, this is irreversable!', resize: false,success:abc });
          }
  
          function emptyText(rowid, cellname, value, iRow, iCol) {
              if (cellname == 'Password')
                  return "";
          }
          function abc(data)
          {
              debugger;
          }
  
  
      and here is my cs code from controller:
  
    [AcceptVerbs(HttpVerbs.Post)]
          public ActionResult TruckDelete(int Id)
          {
              var error = "";
              bool result=true;
              DataContext db = new DataContext();
             Truck udelete= db.Trucks.Where(el =&gt; el.Id == Id).FirstOrDefault();
             if (udelete != null)
             {
                 JobSites_ForSnow snow = db.JobSites_ForSnow.Where(el =&gt; el.TruckId == Id).FirstOrDefault();
                 JobSite normal = db.JobSites.Where(el =&gt; el.TruckId == Id).FirstOrDefault();
                 if(snow==null &amp;&amp; normal==null)
                 {
                 db.Trucks.Remove(udelete);           
                 db.SaveChanges();
                 }
                 else
                 {
                  error = "Truck in use!";
                 result= false;
                 }
             }
             else 
             {
                 error = "Record Not Found!";
                 result= false;
             }
              return Json(result,error);
          }
  </code></pre>
  
  <p>can anybody tell me how can i display the error message? i have seen this answer (<a href="https://stackoverflow.com/questions/8089061/jqgrid-error-message-on-delete">jqgrid error message on delete</a>) but didn't understood what to do :(.  if the question is not clear to you, please let me know by comment, i will explain ...thanks in advance :)</p>