Destroy methods removes item from datasource without server check

4 posts, 0 answers
  1. Jakub
    Jakub avatar
    24 posts
    Member since:
    Jun 2015

    Posted 04 Apr Link to this post

    Hello

    Iam using datasource in kendoGrid. Kendogrid has mode inline, so I can edit add and delete rows. To each method I use my own ajax calls. The problem is that If I delete row, then row is deleted from datasource and then the call to destroy function is made. Thats why I cannot prevent user from deleting this row as it may fail on server side. Is there any option to make it work to say to datasource, first wait for server response then delete row if server succeeded?

    Example:

    http://dojo.telerik.com/UMUSu/2

  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 06 Apr Link to this post

    Hello Jakub,

    Indeed, this is the designed behavior of the widget. However, you should use the DataSource cancelChanges method inside the error event handler in order to revert the deleted record. For example:

    error: function(e)
    {
        this.cancelChanges();
        alert('error');
    }

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Jakub
    Jakub avatar
    24 posts
    Member since:
    Jun 2015

    Posted 08 Apr in reply to Rosen Link to this post

    This generates another problem as it will delete my row, then after I will get response from WebApi and cancel changes, the datasource will add element to grid. Its not acceptable:

    http://dojo.telerik.com/UMUSu/4
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 11 Apr Link to this post

    Hello Jakub,

    Indeed, this is how it is designed to work. As I have mentioned in my previous message, the cancelChanges method will revert changes, making the deleted record to appear in the Grid again.

    When given record is deleted it is removed from the DataSource's data thus, it is removed from the Grid content. Then when the DataSource is synced this record is actually send to the server for deletion. Therefore, with this event flow, it is only possible reverted back, not to prevent it from "disappearing", from the DataSource data when a server error during sync call occurs.

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready