title: Reloading data and afterSubmit, aftersavefunc functions not working in jqGrid using MVC on inline RowAdd or RowSave
body: <p>I'm using jqGrid and doing inline editing and row adding. I'm setting everything up on the client side using Javascript and MVC using C# for the server side code. Everything seems to work fine, except when the inline save and add row functions return from the server. If the save fails or errors out, the client seems to remain unaware of the response. I set up some basic functions to handle the afterSubmit, afterSave, etc., but the only instance when it works is on the refresh action. Whenever I edit or add a row, the response does not seem to come back and the grid is not refreshed. </p>
  
  <p>Everything I have found on this has been the basic set-up of the grid to handle this, but I'm afraid that I may not be returning a proper response or some of my functions are set up incorrectly. 
  I have read the wiki documentation and several posts in the forums here and over at Trirand, but there are gaps in the information that leave me with the same issues.</p>
  
  <p>Just to be clear the editing and adding works fine, as does manual refresh, etc. The only issue is returning a response from the server and reloading the data in the grid after the editing is done.</p>
  
  <p>This is my client code relevant to the grid and functions:</p>
  
  <p>My AfterFunctions:</p>
  
  <pre><code>var actionAfterSubmit = function (response, postdata) {
      var res = response.responseText;
      alert('In actionAfterSubmit');
      return [true, ''];
  };
  
  var actionbeforeSubmit = function (response, postdata) {
      //var res = response.responseText;
      alert('In beforeSubmit');
      return true;
  };
  
  var actionAfterSave = function (rowid, response) {
      alert('In actionAfterSave');
  };
  
  var actionErrorFunc = function (rowid, response) {
      alert('In actionErrorFunc');
  };
  
  var actionSuccessFunc = function (response) {
      alert('In actionSuccessFunc');
      return true;
  
  };      
  </code></pre>
  
  <p>My Grid:</p>
  
  <pre><code>jQuery("#list").jqGrid({
          url: ServiceURL + '/Controller/GetDataAction', //URL that loads data including search functionality
          datatype: 'json',
          mtype: 'GET',
          postData: { tableName: t_Name },
          editData: { tableName: t_Name },
          colModel: col_model, //col_model is passed as parameter
          pager: jQuery('#pager'), //sets pager name
          rowNum: 20, //default number of rows
          rowList: [10, 20, 50, 100], //number of row options
          sortname: 'id', //sorting columns
          sortorder: "asc", //sorting order
          viewrecords: true,
          altRows: true, //enables different styling for alternate rows
          altclass: 'myAltRowClass', //Alternate row styling
          width: "100%",
          height: "100%",
          caption: '',
          navigator: true, //enables navigator toolbar
          multipleSearch: true, //enables multiple search features
          multipleGroup: true, //enables grouping in multiple search
          editurl: ServiceURL + '/Controller/GridSaveAction' //URL that handles edit (insert &amp; update) }); var editOptions = {
          width: 400,
          height: 'auto',
          addCaption: "Add Record",
          editCaption: "Edit Record",
          bSubmit: "Submit",
          bCancel: "Cancel",
          bClose: "Close",
          saveData: "Data has been changed!",
          bYes: "Yes",
          bNo: "No",
          bExit: "Cancel",
          recreateForm: true,
          url: ServiceURL + '/ICMP/MapTable/GridSave/',
          reloadAfterSubmit: true,
          closeOnEscape: true,
          closeAfterEdit: true,
          viewPagerButtons: false,
          afterSubmit: actionAfterSubmit,
          afetrsavefunc: actionAfterSave,
          reloadAfterSubmit: true,
          datatype: 'json'
  
      };
  </code></pre>
  
  <p>My Parameters and other grid setups:</p>
  
  <pre><code>var addOptions = {
          afterSubmit: actionAfterSubmit,
          aftersavefunc: actionAfterSave,
          errorfunc: actionErrorFunc,
          successfunc: actionSuccessFunc,
          afterComplete: refreshTableAfterAddOrEdit,
          reloadAfterSubmit: true
  
      };  
  
  var addParameters = {
          useFormatter: true,
          defaultValue: "",
          useDefValues: true,
          initdata: { tableName: t_Name },
          addRowParams: editOptions,
          reloadAfterSubmit: true  };      
  
  var inlineParameters = {
          edit: false,
          editicon: "ui-icon-pencil",
          save: false,
          saveicon: "ui-icon-disk",
          cancel: false,
          cancelicon: "ui-icon-cancel",
          add: true,
          addicon: "ui-icon-plus",
          addParams: addParameters,
          editParams: editOptions,
          reloadAfterSubmit: true,
          restoreAfterSelect: false            
      };
  
  
  jQuery("#list").jqGrid('navGrid', '#pager', { view: true, edit: true, add: false, del: false, refresh: true, search: true }, editOptions, addParameters, {}, searchOptions, viewOptions);
  
  jQuery("#list").jqGrid('inlineNav', '#pager', inlineParameters);
  
  jQuery("#list").jqGrid('filterToolbar', {
          stringResult: true, searchOnEnter: false, defaultSearch: "cn",
          beforeSearch: function() {
              $("#list").setGridParam({ postData: { _search: true, tableName: t_Name } });
          }    
      });
  
  jQuery("#list").jqGrid('addRow', {
          useFormatter: true,
          useDefValues: true,
          initdata: { tableName: t_Name },
          addRowParams: addParameters
      });
  </code></pre>
  
  <p>This is my Controller</p>
  
  <pre><code>public JsonResult GridSaveAction(string id, jqGridMapTableModel MapRecord, string tableName, FormCollection formCollection, string someVal)
      {
          //Does some things
          try
          {                
            //Sets up update 
            success = DataAccessObject.Update(Query, myParameters); //Runs the update and returns true if success or false if it failed
  
          }
          catch (Exception ex) {
               return Json(ex.Message);    
          } 
          return Json(success ? "Operation succesful." : "Operation failed.");
      }
  </code></pre>
  
  <p>I have been trying everything I can find, but nothing works, and I'm thinking some part of my code is wrong. </p>
  
  <p>Any help is greatly appreciated!</p>