Results 1 to 3 of 3

Thread: NodeInterface destroy with callback?

  1. #1
    Sencha Premium Member
    Join Date
    Jan 2008
    Posts
    113
    Answers
    2

    Default Answered: NodeInterface destroy with callback?

    I have setup a MVC application where I use a JSON Proxy to read and write from my backend. In the application I use grids and trees. Now I noticed a strange behaviour and I am unsure if this is a bug.

    When deleting an entry, I call Model.destroy() with a callback function. This triggers the REST DELETE request to my server, which is fine. Upon success I used to remove the record from the store, so it is removed from the UI.

    Now with grids this works perfectly. With a TreeGrid I have the problem that the node is deleted before the request to my server is even made. Now if there is an error that is a problem, because the UI has already removed the node from the tree.

    Is there a way to bypass the NodeInterface or is this plain a bug with the Node Decoration?

  2. Ok, I am still not sure if this is the desired solution, but this works for me right now:

    Code:
    //NodeInterface otherwise removes node before callback is complete...
    if(model.isNode) {									
    	model.superclass.destroy.call(model, {callback: myCallback}});
    } else {
    	model.destroy({callback: myCallback}});
    }
    and if the operation is successful I call

    Code:
    myCallback = function([..]) {
    	if(record.isNode) {
    		record.remove();
    	} else {
    		store.remove(record);
    	}}
    Maybe this helps someone, or I guess I am the only person that wants to delete tree node remotely and act on the operation result

  3. #2
    Sencha Premium Member
    Join Date
    Jan 2008
    Posts
    113
    Answers
    2

    Default

    Ok, I am still not sure if this is the desired solution, but this works for me right now:

    Code:
    //NodeInterface otherwise removes node before callback is complete...
    if(model.isNode) {									
    	model.superclass.destroy.call(model, {callback: myCallback}});
    } else {
    	model.destroy({callback: myCallback}});
    }
    and if the operation is successful I call

    Code:
    myCallback = function([..]) {
    	if(record.isNode) {
    		record.remove();
    	} else {
    		store.remove(record);
    	}}
    Maybe this helps someone, or I guess I am the only person that wants to delete tree node remotely and act on the operation result

  4. #3
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    9

    Default Error occurs when the server return "success" true

    Your solution works only if record is failed to be deleted on server and server returns "success:false"

    But if the record successfully deleted and server returns "success:true" an error popus up in console saying no method "indexOf" on store.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •