kendo grid cancel edit on nested datasource

江枫思渺然 提交于 2019-12-11 14:27:53

问题


I have viewmodel with nested json datasource.

Here is my DEMO (use second contact "personal contact" for testing)

[{ person_id:1, person_name:"John", 
   contact: [
    {email:"john@domain.com"}
   ]
}]

I am binding videmodel to grid with contacts detail template:

+ person
  => contact 1
  => contact 2

Grid is editable using custom popup editor template, where I can edit person and contacts all in one form. Available personal contacts are presented using listview with form above it (click on the row binds fields).

My problem lies with canceling edit. Because contacts grid detail listview is binded to a data subset, it is not automatically synced to a before edit state. I don't want to resync whole grid, just force that contact detail listview to rebind.

Is there any "smart" way to make detail listview aware of a data change? I am creating and binding detail listview at detailInit. Maybe store record id somewhere with listview and rebind it on grid cancel event?

Because data store is nested only top level responds correctly to the update and cancel actions. Nested (listview) levels doesn't in at least two ways: (1) when you edit top and nested item and update, grid will refresh, but detail listview will not (2) when you edit top and nested level and update, then open edit again and simply cancel, nested level is not persisted when editor is again opened - data is rolled back to its original state (?). All this points to store nested level not being handled correctly "by default" and some smarter way around is required which I lack knowledge or ideas.


回答1:


Found out that editing misbehaved due to missing "record id". Once I provided unique id I am getting expected results.



来源:https://stackoverflow.com/questions/48183283/kendo-grid-cancel-edit-on-nested-datasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!