jQuery中datagrid使用getChanges获取改变行数据一直为空[]的问题?

问题代码:

$('#dg').datagrid('acceptChanges');

var rows = $('#dg').datagrid('getChanges');

不论怎么修改数据,rows总是[]


通过查API可以发现

getChanges type 获取最后一次提交以来更改的行,type 参数表示更改的行的类型,可能的值是:inserted、deleted、updated,等等。当 type 参数没有分配时,返回所有改变的行。

acceptChanges none 提交自从被加载以来或最后一次调用 acceptChanges 以来所有更改的数据。


getChanges是获取最后一次提交以来更改的行,而acceptChanges是提交修改后的数据,所以当调用getChanges时,acceptChanges已经提交了所有改变的数据,所以在通过getChanges获取改变行时为空。


正确代码:

var rows = $('#dg').datagrid('getChanges');

获取所有改变行的数据,如果没有修改返回[]

---------------------

作者:AdamSun_

来源:CSDN

原文:https://blog.csdn.net/qq_28940573/article/details/97041399

版权声明:本文为博主原创文章,转载请附上博文链接!

你可能感兴趣的:(jQuery中datagrid使用getChanges获取改变行数据一直为空[]的问题?)