Reputation: 662
I'm working with a grid which has a popup edit. We have a custom method for edit, add and cancel that does a little extra logic (nothing fancy). We've been finding that if you edit a record, change some of the data, but then click cancel, the data in the grid remains editted. I was able to reproduce it on one of the demo's from the API documentation.
The cancel event is basic, just:
cancel: function(e) {
e.sender.refresh();
e.preventDefault()
}
Here's the link to a working example:
Literally the only thing I changed from the original API documentation example was I added e.sender.refresh()
before the e.preventDefault()
.
If you change Jane Doe to John Doe, click outside the text box, then click cancel, the grid will now say John Doe, even though you clicked cancel.
Any ideas whats going on or how to fix it?
Upvotes: 0
Views: 1379
Reputation: 662
For anyone that ends up here, I finally figured out what was going on.
It seems silly that I should have to specify the cancel event when all I want to do is use the default cancel functionality. So I removed the method, which then would end up deleting the row altogether. This brought me to this post:
Kendo grid cancel causing deletion of row
After deleting the "custom" cancel method on my grid options, I added the following line of code in my datasource:
model: { id: "Key" . . . }
Works like a charm now. Apparently it needs a specified id field in the datasource in order to cancel properly.
Upvotes: 0