JqGrid does not save inline row changes

I am working with jqGrid 4.3.2 on the ASP.NET MVC 4 website, jQuery 1.7.2. There are several places in an application that uses jqGrid. My general setup right now is that all editing is done locally ( loadonce: true and clientArray ) with built-in navigation and editing, and all grid data is sent to the server when the form is submitted via AJAX calls. I ran into some difficulties editing lines and in what events they were committed. You can view the site (and the source, the overall work in the process, be beautiful) here . If you add or edit a line, and then click elsewhere on the page, line editing will not be saved. The user must press the enter key somewhere while editing a line to save the line.

I touched a little on this question, which Oleg was kind enough to answer. Is there a way to fix line editing, besides, when the enter key is pressed, for example, when a line loses focus, is it possible?

+6
source share
2 answers

What you can do is the following:

  • First of all, you should set restoreAfterSelect: false option inlineNav . I see that this parameter is not documented, but you can see it in the source code . Without configuration, inlineNav used beforeSelectRow to call restoreRow (see here ).
  • Implement saving the previous edit line inside onSelectRow (see the answer code) or inside beforeSelectRow . Probably using beforeSelectRow will be even simpler because the last edit line that you want to save can only be the last selected line that you can get from the selrow option, because the value has not changed inside beforeSelectRow .
+8
source

For those who read this in 2016, this functionality is now included in jqGrid. See https://github.com/tonytomov/jqGrid/issues/785 . At the time of writing, jqGrid 5.1 has been released, so I expect this functionality to be available from version 5.2 onwards. Or just get the latest code from GitHub.

To use it, just set the following properties on your jqGrid:

 ... restoreAfterSelect: false, saveAfterSelect: true, ... 

Now you no longer need to implement your own solution.

+1
source

Source: https://habr.com/ru/post/918022/


All Articles