问题
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