Kendo Grid:取消编辑将删除新行 [英] Kendo Grid: Canceling edit deletes new row

查看:255
本文介绍了Kendo Grid:取消编辑将删除新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我遇到的行为的演示.

如果您编辑ID为1的现有行,则将文本更改为其他内容,然后按取消"按钮,该行将正确还原为以前的状态.

If you edit the existing row with id 1, change the text to something else and then press the cancel button, the row is reverted correctly to its previous state.

为了重现我的问题,您需要:

In order to reproduce my problem you need to:

  • 添加新行
  • 按下更新按钮将其保存.
  • 再次选择该行,然后按更新按钮.
  • 按下取消按钮
  • 该行消失了!

即使在这个问题上有类似的问题,我仍未找到满意的答案.

Even though there are similar questions on this problem, I have yet to find a satisfactory answer.

有人说我需要定义一个ID.从我的演示中可以看到,这没有什么区别,新行具有一个ID,并且仍然消失.

Some people say that I need to define an id. As you can see from my demo, this does not make any difference, the new row has an id and it still disappears.

使用远程数据源时有一些建议,但这在我的情况下不起作用,我需要使用本地数据.

There are some suggestions when you are using a remote datasource, but this does not work in my case, I need to use local data.

最后,有答案.虽然确实可以防止新行消失,但是取消该行不会将数据恢复为旧状态,而是仅关闭编辑器,并且数据保持编辑后的状态.

Finally, there is this answer. While it does prevent the new row from disappearing, Canceling the row does not revert the data to its old state, it only closes the editor and the data are as they where after the edit.

推荐答案

出现相同的问题.我可以通过简单地调用DataSource的cancelChanges()方法来解决它:

Had the same problem. I had it solved by simply calling the cancelChanges() method of the DataSource:

..
cancel: function(e) {
            $('#mainGrid').data('kendoGrid').dataSource.cancelChanges();
        },
..

这篇关于Kendo Grid:取消编辑将删除新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆