If I have a node in a HierarchicalDataSource, and I want to sync changes to it, I assume I should call
node.parentNode().children.sync()
When I call this, the resulting data packet contains, as its 'id' property, the id of the parentNode, not of the child.
This seems to be due to the fact that kendo.data.Node's _initChildren function indiscriminately applies the parent's identity to the request's data object.
Clearly, that makes no sense for update/delete actions, where some other property would make more sense, or the ability to include or not include the parent property.
Arguably, the entire path should be available, for situations where a node can exist in multiple places in the tree.
I suppose I could overcome this with the data: property being a function, but I think the basic assumption is mistaken.
6 Answers, 1 is accepted
Would you elaborate in more detail on the widgets you are using? Also please describe the scenario you would like to implement.
Have in mind that currently the widgets that are aware of HierarchicalDataSource are TreeView and PanelBar. If you would like to have a widget that supports editing I would suggest using the TreeList and DataSource.
Regards,
Viktor Tachev
Progress Telerik
So a parent might be a region, and its child might be a brand, and that item's child might be a product, and they all have differing properties that don't suit them to being displayed in the same grid.
Additionally, when performing a node.parentNode().children.sync() to update a field in a node with children, that sync call either
1. removes node's own children (never runs _updateChildrenField and simply overwrites the node[childrenFieldName] array, even though node.children is still populated with existing (and possibly new) records, or
2. replaces the node's node[childrenFieldName] array with the JSON from the server, without processing those values as new models, just applying the array to the node[childrenFieldName
The work-around I've used is to always call
node._updateChildrenField();
node.children.trigger("change");
after every "update" sync on a node that has children.
I am glad that you have the functionality up and running. Thank you for sharing your approach.
With that said, have in mind that the TreeView and PanelBar components are not intended for CRUD operations. If you would like to use editing and the TreeList is not suitable you can use the Grid component.
Regards,
Viktor Tachev
Progress Telerik