jqGrid-内联编辑-检测脏/已更改的单元格

问题描述:

有使用jqgrid的getChangedCells的示例 确定数据是否已更改的方法?

is there an example of using jqgrid's getChangedCells method to determine if data has changed?

我在可下载的演示中为getChangedCells添加了g jqgrid,只能找到函数定义,不能找到 getChangedCells的示例用法.

I grepped getChangedCells in the downloadable demos for jqgrid, and could only find the function definition, not example usages of getChangedCells.

我要做的是保存用户的修改 如果用户单击另一行则进行此操作.但是,我只 要在行很脏的情况下提交保存.

What I want to do is save the edits that a user's made if the user clicks on another row. But, I only want to submit the save if the row is dirty.

预先感谢, -内特

该行上没有安全的脏标志.您可以使用以下事实:在行编辑开始时(在在线编辑模式)方法 editRow editable="1"属性添加到网格行(<tr>元素).之后,方法 saveRow .因此,当前页面的行在内联编辑模式下至少存在一次,将具有editable属性.如果表格元素的ID为列表",则可以使用

There are no safe dirty flag on the row. You can use the fact that at the beginning of row editing (at the start of the inline editing mode) the method editRow add editable="1" attribute to the grid row (<tr> element). Later the methods saveRow and restoreRow changes the attribute value to editable="0". So the rows of the current page which was at least once in the inline editing mode will have the editable attribute. If the id of the table element is "list" you can find the edited rows with

$("#list tr[editable]")

集合元素的id是行的rowid.

The ids of the elements of the set are the rowids of the rows.

如果在网格中使用分页,则应注意并在更改页面之前将已编辑行的ID保存在当前页面上. onPaging 事件将在这里为您提供帮助.

If you use paging in the grid you should be careful and save the ids of the edited rows on the current page before the changing of the page. The onPaging event would help you here.

我认为,执行所需操作的最佳,最安全的方法是使用 saveRow 方法(可能您仅直接使用 editRow ).在aftersavefunc函数内部,您可以将修改后的行的ID保存在数组/映射中.这样可以解决您的问题并可以安全地工作.

In my opinion the best and the most safe way to do what you need is to use aftersavefunc parameter of the editRow or saveRow methods (probably you use directly only editRow). Inside of your aftersavefunc function you can save the id of the modified row in an array/map. This will solve your problem and will safe work.