0

I am using jqgrid to display grid data. For editing I am using inline edit. What I want is in case of Error response from sever when POST request is made, not to restore the edited row. I want the row to stay in edit form until the response is without any error. I have this example which is not working. I red about the same problem in this question Reset again and persist the data of JqGrid Row in Editable mode when some error return from Server. What did I miss in my code ?

$(obj.grid).jqGrid('saveRow', eRowId, {
                        aftersavefunc: saveRow,
                        url: ...,
                        mtype: "POST",
                        "restoreAfterError": false,
                    });

var saveRow = function (rowid, response) {
            if (response.Error) {

            }
            else {
                return [false, "error message to display the user"];
            }
          }
Community
  • 1
  • 1
TheChampp
  • 1,337
  • 5
  • 24
  • 41

1 Answers1

1

You use wrong callback of saveRow. You should use successfunc instead of aftersavefunc.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • It works now, but the enter and esc does not work now. What could be wrong ? – TheChampp Nov 30 '15 at 17:10
  • @TheChampp: You should just use correct options. To have support of Enter and Esc you should call `editRow` (you don't included the call in your question) with the option `keys: true`. – Oleg Nov 30 '15 at 17:13
  • @TheChampp: `keys:true` should be added to the options of `editRow`, not to `saveRow`. `editRow` can register `keydown` event handler and to force call of `saveRow` or `restoreRow` if the user press Enter or Esc key. `saveRow` don't support any `keys:true` option. – Oleg Nov 30 '15 at 20:04