Consider the following scenario:
- Local dataSource is populated with .data()
- A new data item is added to the dataSource using .add()
- .cancelChanges() is called on the dataSource, item in #2 disappears
I tried inserting a .sync() call after item #2, but I found that .cancelChanges() will always remove newly added items to the DataSource that were added using .add(). After doing some additional research, I'm beginning to question exactly how local DataSource's are supposed to be used. I've seen a lot of mention of having to use the four transport methods, and that the changes themselves should actually be persisted to a Javascript array, and after a .add(), the array should be updated and the .data() method should be called again. How exactly should this be implemented?
I've put together a Dojo that illustrates the behavior from which I will base these questions:
http://dojo.telerik.com/uYaYI/4
In the initialization block, if I add each of my initial 25 items via .add(), then click on any one of them and hit "Cancel" then they are actually removed from the data source. If I instead put my initial items in an array and call .data(), then the .cancelChanges seems to work as expected. However, if I use the .add() method, then "Save," then try to hit it and then hit "Cancel" again I see that the item disappears. When doing CRUD operations on a local dataSource, is it required that the data be persisted to a Javascript array? For clarity, could someone explain why this is?