Results 1 to 4 of 4

Thread: Delete recently added leaf on a tree

  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    49
    Vote Rating
    1
      0  

    Default Delete recently added leaf on a tree

    I have a tree and each time a leaf is added to a node, I do an ajax call. It works fine but when it fails, on failure function, the leaf is still added even though the error message that I put shows up.. so what I want to do is on failure function I want to remove that added leaf... I did this but this does not work

    Code:
    var temp2 = Ext.StoreMgr.lookup('myStore').tree.root.childNodes[0];
                                        console.log(temp2);
                                        Ext.StoreMgr.lookup('myStore').tree.root.removeChild(temp2);
    is there a better way to do this?

  2. #2
    Sencha Premium Member sencha-dev2's Avatar
    Join Date
    Jun 2012
    Location
    France
    Posts
    59
    Answers
    2
    Vote Rating
    0
      0  

    Default

    Hi, I used this to destroy a leaf on a tree panel when I close the corresponding tab.

    Code:
    var root = Ext.getCmp('treePrincipal').getRootNode();            
    var parent = root.findChild('id', 'rootBeneficiaire');
    var child = parent.findChild('id', this.id);
    child.destroy();
    It works well on a beforeclose event, I think you can adapt to your case.
    The properties you set on your treepanel can help you to find its elements, do NOT use this.id as you probably won't refer to the node. I set mine in order to have the same ids for my panel and the corresponding node.
    Hope it'll help.

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    72
    Answers
    7
    Vote Rating
    1
      0  

    Default

    I'm not sure, but simply try

    Code:
    temp2.remove();

  4. #4
    Sencha User
    Join Date
    Sep 2012
    Posts
    49
    Vote Rating
    1
      0  

    Default

    I tried but it refreshes my tree but the leaf is still there

Tags for this Thread

Posting Permissions

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