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

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

问题描述

这是一个关于我正在经历的行为的演示.

Here is a demo to for the behavior I am experiencing.

如果您编辑 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.

推荐答案

遇到了同样的问题.我通过简单地调用数据源的 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天全站免登陆