jqGrid不保存内联行编辑 [英] jqGrid not saving inline row edits
问题描述
我正在使用ASP.NET MVC 4网站jQuery 1.7.2中的jqGrid 4.3.2.在应用程序中有几个地方使用了jqGrid.现在,我的一般设置是,所有编辑都通过内联导航和编辑在本地完成(loadonce: true
和clientArray
),并且所有网格数据都通过AJAX调用以表单提交的形式发布到服务器上.我在行编辑以及提交什么事件时遇到了一些困难.您可以在此处查看该网站(以及资源,正在开展的总工作,很好).如果添加或编辑行,然后单击页面上的其他位置,则不会保存行编辑.用户必须在行编辑过程中的某处按Enter键才能保存行.
I'm working with jqGrid 4.3.2 in an ASP.NET MVC 4 website, jQuery 1.7.2. There are several places in the application where jqGrid is used. My general setup right now is that all editing is done locally (loadonce: true
and clientArray
) with inline navigation and editing, and all grid data is posted to the server on form submit via AJAX calls. I've run into some difficulty with row edits and at what events they are committed. You can view the site (and source, total work in progress, be nice) here. If you add or edit a row and then click somewhere else on the page, the row edit is not saved. The user has to hit the enter key somewhere during the row edit in order to save the row.
我在这个问题( Oleg 足以回答.除了按下Enter键之外,是否还有其他方法可以提交行编辑,例如当行失去焦点时?
I touched on this a little bit in this question, which Oleg was kind enough to answer. Is there a way to commit a row edit other than when the enter key is pressed, like when the row loses focus maybe?
推荐答案
您可以执行以下操作:
- 首先,您必须设置restoreAfterSelect: false选项. > inlineNav .我看到该选项没有记录,但是您可以在源代码.没有设置
inlineNav
会使用beforeSelectRow
调用restoreRow
(请参阅答案中的代码)内保存上一个编辑行beforeSelectRow
.beforeSelectRow
的用法可能会更容易,因为需要保存的最后编辑行可能只是可以从selrow
选项获得的最后选择的行,因为该值尚未在beforeSelectRow
内部更改
- First of all you have to set
restoreAfterSelect: false
option of inlineNav. I see that the option is not documented, but you can see it in the source code. Without the settinginlineNav
usesbeforeSelectRow
to callrestoreRow
(see here). - Implement saving of the previous editing row inside of
onSelectRow
(see the code from the answer) or inside ofbeforeSelectRow
. Probably the usage ofbeforeSelectRow
will be even easier because the last editing row, which need be saved, could be only the last selected row which you can get fromselrow
option because the value is not yet changed inside ofbeforeSelectRow
.
这篇关于jqGrid不保存内联行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!