This is a migrated thread and some comments may be shown as answers.

Cannot restore original TreeList data after a failed delete/destroy CRUD operation - TreeListDataSource

6 Answers 186 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Paolo
Top achievements
Rank 1
Paolo asked on 21 Nov 2017, 01:46 PM

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:

  1. TreeList is empty
  2. User inserts Root Node R1
  3. User inserts Node C1 as child of R1
  4. User inserts Node D1 as child of C1
  5. User tries to delete R1
  6. Server throws exception about user cannot recursively delete nodes ( we don't allow recursive / tree deletions )
  7. App catch exception in ourTreelist.dataSource.error callback and call ourTreelist.dataSource.cancelChanges()
  8. 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

Sort by
0
Stefan
Telerik team
answered on 23 Nov 2017, 08:06 AM
Hello, Paolo,

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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paolo
Top achievements
Rank 1
answered on 23 Nov 2017, 12:08 PM

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

 

 

0
Stefan
Telerik team
answered on 27 Nov 2017, 09:26 AM
Hello, Paolo,

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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paolo
Top achievements
Rank 1
answered on 20 Mar 2018, 12:17 PM
Hi Stefan , could we earn some telerik points as Send a bug report ? Thanks
0
Accepted
Stefan
Telerik team
answered on 21 Mar 2018, 09:53 AM
Hello, Paolo,

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
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paolo
Top achievements
Rank 1
answered on 23 Apr 2018, 09:57 AM
Thanks Stefan, sorry for late response
Tags
TreeList
Asked by
Paolo
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Paolo
Top achievements
Rank 1
Share this question
or