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

4 posts, 0 answers
  1. Paolo
    Paolo avatar
    16 posts
    Member since:
    Mar 2017

    Posted 21 Nov Link to this post

    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

     

  2. Stefan
    Admin
    Stefan avatar
    1389 posts

    Posted 23 Nov Link to this post

    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.
  3. Paolo
    Paolo avatar
    16 posts
    Member since:
    Mar 2017

    Posted 23 Nov in reply to Stefan Link to this post

    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

     

     

  4. Stefan
    Admin
    Stefan avatar
    1389 posts

    Posted 27 Nov Link to this post

    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.
Back to Top