Kendo ListView and MVVM 'edit template' cancel button resets bound data to initial state

时间:2017-06-15 09:34:24

标签: kendo-ui kendo-listview

I have a Kendo ListView bound to an Observable object and all is working well.

I'm able to:

  • Add items to the list
  • Edit existing items by using the edit template below
  • Delete items

One oddity though is when I switch an item to edit view and click Cancel it resets all data back to the original data. So if I started with one item with say name and amount fields, I edit the item and change the amount, then add two more items to the list all is well. But then I click edit on any of the items and immediately click cancel, from here it removes all the additional items I added and resets the data for the first item back to what it was at the beginning.

Why would the cancel action do that?

This dojo snippet shows the exact problem I'm having: http://dojo.telerik.com/IKowo

Kendo version 2016.3.1118

EDIT: One further development, I found a forum post on Telerik stating that you have to have an ID column and a schema:model:id setup otherwise things won't work as expected.

I've updated the dojo snippet as follows: http://dojo.telerik.com/IKowo/2

Since adding the ID to the mix it looks like the amounts aren't being affected by the cancel button but the newly added items still get removed.

1 个答案:

答案 0 :(得分:0)

按照telerik在此处提供的示例

///将Listview绑定到本地数据数组并执行CRUD http://dojo.telerik.com/eWih/2

取消事件不删除新项目的唯一要求是:

  • 将新项目添加到数据源时,id字段应保持为0
  • 它应该在数据源transport.create事件中增加/更新(必需)

快乐的编码!