Results 1 to 2 of 2

Thread: NodeInterface removeAll() removes related node data too early

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-8756 in 4.2.0.663.
  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    21
    Vote Rating
    5
      0  

    Default NodeInterface removeAll() removes related node data too early

    Hello again,

    In 4.2.0.489 the NodeInterface.removeAll() function sets the previousSibling, nextSibling, and parentNode values of all childNodes to null before it fires the 'remove' event.

    This causes a TreeStore.reload() call with a "node" specified in the options object to remove more nodes than it should when reloading a node with at least one child node and one grandchild node expanded. The issue is in NodeStore.onNodeRemove() when it calls onNodeCollapse(). onNodeCollapse() tries to figure out where the node is in the tree, and since it's parent and sibling nodes have already been set to null it just removes the rest of the tree.

    Here is an example
    Code:
    Ext.create('Ext.tree.Panel', {
        dockedItems: [
            {
                xtype: 'toolbar',
                dock: 'top',
                items: [
                    {
                        xtype: 'button',
                        text: 'Test',
                        handler: function() {
                            var me = this;
                            var store = me.up('treepanel').getStore();
                            var item = store.getById('p4');
                            item.removeAll();
                        }
                    }
                ]
            }
        ],
        store: Ext.create('Ext.data.TreeStore', {
            root: {
                text: 'Ext JS',
                id: 'root',
                expanded: true,
                children: [
                    {
                        text: 'parent',
                        id: 'p1',
                        expanded: true,
                        children: [
                            {
                                text: 'Parent 4',
                                id: 'p4',
                                expanded: true,
                                children: [
                                    {
                                        text: 'Parent 3',
                                        id: 'p3',
                                        expanded: true,
                                        children: [
                                            {
                                                text: 'Parent 2',
                                                id: 'p2',
                                                expanded: true,
                                                children: [
                                                    {
                                                        leaf: true,
                                                        text: 'child 1',
                                                        id: 'p2c1'
                                                    },
                                                    {
                                                        leaf: true,
                                                        text: 'child 2',
                                                        id: 'p2c2'
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                text: 'Parent 5',
                                id: 'p5',
                                expanded: true,
                                children: [
                                    {
                                        leaf: true,
                                        text: 'child 1',
                                        id: 'p4c1'
                                    },
                                    {
                                        leaf: true,
                                        text: 'child 2',
                                        id: 'p4c2'
                                    }
                                ]
                            }
    
    
    
    
                        ]
                    }
                ]
            },
            folderSort: true,
            sorters: [
                {
                    property: 'text',
                    direction: 'ASC'
                }
            ]
        }),
        title: 'Tree Edge case Tester',
        useArrows: true
    })
    If you click the "Test" button you will see that not only does Parent4 dissapear, but everything below it goes away as well.


    The solution seems to be to not alter the nodes position in the tree until after it has been removed.

    Hope that helps!

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Thanks for the report.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

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