Hi
We have a problem relative to undoing changes on a TreeList,we don't allow recursive delete on TreeList, so after an user tries to delete a node with children he must receive am alerts and modification should be undone.
Tha problem is cancelChanges() cannot restore node's children the user is triyng to delete.
The TO-BE scenario we need for our application is:
- TreeList is empty
- User inserts Root Node R1
- User inserts Node C1 as child of R1
- User inserts Node D1 as child of C1
- User tries to delete R1
- Server throws exception about user cannot recursively delete nodes ( we don't allow recursive / tree deletions )
- App catch exception in ourTreelist.dataSource.error callback and call ourTreelist.dataSource.cancelChanges()
- following nodes are restored : R1, C1, D1
Example TreeList hierarchy
R1 ( deleting R1 remove cannot be done because it would remove also C1 and D1 )
-> C1
-> D1
But in our tests after deleting R1 and receving error from server we cannot use cancelChanges() to entirely restore previous situation, only R1 is restored but children miss.
I attach before (delete) and after (delete) image to explain better
Thanks
6 Answers, 1 is accepted
Thank you for the details.
Based on the description, the issue may occur if the nodes C1 and D1 are not correctly saved in the database. If they are not saved calling cancelChanges will remove all unsaved items.
If the items are saved, please check if calling refresh on the error callback will restore the items in the TreeList.
If the issue still occurs, please provide a fully runnable example and I will gladly assist.
Regards,
Stefan
Progress Telerik
Hi Stefan, thanks for your quick answer
We prepared a code example for you where a custom local data transport mimics returning error after a destroy CRUD operations
In our application inside the dataSource.error we run dataSource.cancelChanges() in the same way, we obtain the same result the children are not restored by dataSource.cancelChanges() so we need to call dataSource.read() but calling cancelChanges() would be preferred to not refresh entire TreeList , that in some cases could be expanded and very long
http://dojo.telerik.com/oxAWE/3
Thanks
Thank you for the example.
I forwarded it to the developers' team, the internal logic is to delete the items in the dataSource from bottom to top starting from the lowest nodes. Once the error is returned, the child nodes are already removed from the dataSource. That is why an additional read is required.
As this is intended result, we will log it as an enhancement as we can agree that the current behavior can be improved to omit the additional read request.
I have logged it in our GitHub repository:
https://github.com/telerik/kendo-ui-core/issues/3795
Regards,
Stefan
Progress Telerik
Yes of course.
The points were not added initially as this is considered an enhancement more than an issue.
Still, the report is a valid one and could improve the widget performance and make it more intuitive and this deserves the points.
Regards,
Stefan
Progress Telerik