使用jqGrid getChangedCells,然后将更改标记为不脏 [英] Using jqGrid getChangedCells, and then marking the changes as not dirty
问题描述
我正在将jqGrid与getChangedCells('all')配合使用,以获取网格中已更改的行的数组.我将这些行发送到服务器以保存它们.效果很好.
I'm using jqGrid with the getChangedCells('all') to get an array of the rows in the grid which has been changed. I send the rows to the server to save them. This works fine.
问题是,我找不到将行取消标记为脏行的方法.例如,例如theGrid.setClean()或类似的东西,当服务器返回成功的保存调用时调用.
The problem is, I can't find a way to un-mark the rows as dirty. Like for example theGrid.setClean() or something similar, which to call when the server returns a success for the save-call.
有人知道如何实现吗?
编辑-找到解决方案:
通过添加以下代码,解决了该问题.我不知道这是否是最好的方法.似乎至少在此刻有效.
By adding the following code, the problem is solved. I don't know if this is the best approach. It seems to work at this moment at least.
$(".edited").removeClass("edited");
$(".dirty-cell").removeClass("dirty-cell");
推荐答案
您只需从保存在服务器上的行(<tr>
)中删除"edited"
类,并从单元格中删除"dirty-cell"类( <td>
).例如
You can just remove "edited"
class from the rows (from <tr>
) which is saved on the server and "dirty-cell" class from cells (<td>
). For example
var $tr = $($grid.jqGrid('getInd', rowid, true));
$tr.removeClass("edited");
$tr.children("td").removeClass("dirty-cell");
这篇关于使用jqGrid getChangedCells,然后将更改标记为不脏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!