Results 1 to 2 of 2

Thread: [FIXED-1030] Unable to delete tree node when it hasn't been rendered yet

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    May 2007
    Location
    Aalborg, Denmark
    Posts
    16

    Default [FIXED-1030] Unable to delete tree node when it hasn't been rendered yet

    Ext version tested:
    • Ext 3.2.1


    Adapter used:
    • ext


    css used:
    • only default ext-all.css


    Browser versions tested against:
    • FF3.6.4 (firebug 1.5.4 installed)


    Operating System:
    • WinXP Pro


    Description:
    When trying to delete the last child of a tree node which hasn't been rendered yet, you get an error saying "this.ctNode is undefined". This is because the parent node is collapsed with no regard to whether it has been rendered or not.

    Test Case:

    Code:
    var r = new Ext.tree.TreeNode({
        text: 'root',
        expanded: true,
        leaf: false
    });
    
    var n1 = new Ext.tree.TreeNode({
        text: 'node1',
        expanded: true,
        leaf: false
    });
    
    var w = new Ext.Window({
        layout: 'fit',
        title: 'Tree window',
        width: 200,
        height: 200,
        items: [
        {
            xtype: 'treepanel',
            title: 'Tree Panel',
            root: r
        }]
    });
    
    //w.show();
    
    r.appendChild(n1);
    r.removeChild(n1);
    Steps to reproduce the problem:
    • Just run the code above in a page which has Ext 3.2.1 loaded. It will give the described error. Try removing the comment from the w.show() line and run it again. The error is gone and a window with a tree panel and a single node 'root' is visible.


    Possible fix:
    This override fixes the problem but I'm not sure it is the right place to fix it. My changes in red.
    Code:
    Ext.override(Ext.tree.TreeNode, {
       // private override
       removeChild: function(node, destroy)
       {
          this.ownerTree.getSelectionModel().unselect(node);
          Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
          // only update the ui if we're not destroying
          if (!destroy)
          {
             // if it's been rendered remove dom node
             if (node.ui.rendered)
             {
                node.ui.remove();
             }
             if (this.childNodes.length < 1)
             {
                if (node.ui.rendered)
                {
                   this.collapse(false, false);
                }
             } else
             {
                this.ui.updateExpandIcon();
             }
             if (!this.firstChild && !this.isHiddenRoot())
             {
                this.childrenRendered = false;
             }
          }
          return node;
       }
    });

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,255

    Default

    Thanks for the report, it's been corrected in SVN for 3.3.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Similar Threads

  1. Tree node and delete entry
    By pactgmbh in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 24 Jan 2011, 9:20 PM
  2. Replies: 1
    Last Post: 20 May 2010, 9:06 AM
  3. Tree Node 'rendered' event
    By ewg in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 3 Feb 2009, 6:12 AM
  4. right-click delete node from tree?
    By vn_beth in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 24 Apr 2008, 11:44 AM

Posting Permissions

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