简体   繁体   中英

kendo grid cancelChanges issue

I am working on a web application using kendo grid(Angular JS). I should call grid.saveChanges() after every delete or insert operation. But in a special scenario such as

  1. Insert a record and call saveChanges
  2. Then delete the same record and call saveChanges
  3. Then call the call grid.cancelChanges()

Normally it goes back to last saveChanges state but in my case it is showing the deleted row. Any help?

I've tried what you say in this demo: http://demos.telerik.com/kendo-ui/grid/editing but it works correctly.

Maybe it only works when you call saveChanges() manually. Data to restore when you're calling cancelChanges() is stored in _pristineData property so try this workaround:

var grid= $("#YourGrid").data("kendoGrid");
grid.saveChanges();
grid.dataSource._pristineData = grid.dataSource._data;

最终我找到了解决方案。我的问题与唯一ID有关。保存数据后,我更改了grid.dataSource.data()项目的ID。因此,grid.dataSource._pristineData和grid.dataSource之间的映射。 _data坏了,所以我的解决方案是也更改grid.dataSource._pristineData的ID,现在可以使用了,谢谢。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM