开发者

How do I prevent jqGrid from restoring the row after saving

开发者 https://www.devze.com 2023-01-08 23:17 出处:网络
I have a jqGrid in inline editing mode. When the user hits Enter, the record is sent to the ser开发者_如何学Pythonver to save. The server returns a success:true or false which I handle in successFunc

I have a jqGrid in inline editing mode. When the user hits Enter, the record is sent to the ser开发者_如何学Pythonver to save. The server returns a success:true or false which I handle in successFunc as follows:

function successFunc(data) {
  d = jQuery.parseJSON(data.responseText);
  if (!d.success) { alert(d.message); }
  return d.success;
}

What I would like is that when d.success is false, the jqGrid should remain in edit mode and not restore. I tried adding a throw "exit" call after the alert. It works, but the Esc and Enter keys do not work any longer.

Is there any way to prevent jqGrid from restoring the row after save?

Thanks


The call to saveRow supports an afterrestorefunc callback:

afterrestorefunc if defined, this function is called in restoreRow (in case the row is not saved with success) method after restoring the row. To this function we pass the rowid

So you could let the grid call restoreRow and then in your callback you can call editRow to force the grid back in to edit mode. Not an ideal solution, but the transition will happen so fast the user probably will not notice.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号