Results 1 to 2 of 2

Thread: TreeList throws exception with dynamic setRoot

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default TreeList throws exception with dynamic setRoot

    Test Case: https://fiddle.sencha.com/#view/editor&fiddle/2lse

    Run the test case, see there's an exception thrown in the console in onNodeAppend.

  2. #2
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Potential fix:

    Code:
    Ext.define(null, {
        override: 'Ext.data.TreeStore',
    
        updateRoot(newRoot, oldRoot) {
            this.fireEvent('beforerootchange', newRoot, newRoot, oldRoot);
            const initial = this.isConfiguring;
            // The rest of the fn
        }
    });
    
    Ext.define(null, {
        override: 'Ext.list.Tree',
    
        updateStore: function(store, oldStore) {
            let root;
    
            if (oldStore) {
                // Store could be already destroyed upstream
                if (!oldStore.destroyed) {
                    if (oldStore.getAutoDestroy()) {
                        oldStore.destroy();
                    } else {
                        this.storeListeners.destroy();
                    }
                }
                this.removeRoot();
                this.storeListeners = null;
            }
    
            if (store) {
                this.storeListeners = store.on({
                    destroyable: true,
                    scope: this,
                    filterchange: 'onFilterChange',
                    nodeappend: 'onNodeAppend',
                    nodecollapse: 'onNodeCollapse',
                    nodeexpand: 'onNodeExpand',
                    nodeinsert: 'onNodeInsert',
                    noderemove: 'onNodeRemove',
                    beforerootchange: 'onBeforeRootChange',
                    rootchange: 'onRootChange',
                    update: 'onNodeUpdate'
                });
    
                root = store.getRoot();
                if (root) {
                    this.createRootItem(root);
                }
            }
    
            if (!this.destroying) {
                this.updateLayout();
            }
        },
    
        privates: {
            onBeforeRootChange() {
                this.rootChanging = true;
            },
    
            onRootChange(root) {
                this.rootChanging = false;
                this.callParent([root]);
            },
    
            onNodeAppend(parentNode, node) {
                if (this.rootChanging) {
                    return;
                }
                this.callParent([parentNode, node]);
            }
        }
    });
    IMO the initial flag is incorrectly set only if we didn't have a root before. The intent is to not do those things during construction, however the root can come at a later time.

Similar Threads

  1. Combined Static and Dynamic TreeList
    By pauldugas in forum Ext JS 6.x Q&A
    Replies: 2
    Last Post: 31 May 2016, 6:20 PM
  2. Admin Dashboard dynamic/remote treelist
    By wemerson.januario in forum Ext JS 6.x Q&A
    Replies: 2
    Last Post: 22 Jan 2016, 4:31 AM
  3. alignTo throws exception
    By stevebla in forum Ext: Q&A
    Replies: 1
    Last Post: 25 Mar 2013, 7:56 AM
  4. appendChild throws DOM Exception 8
    By rijkvanwel in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 16 Mar 2011, 7:07 AM
  5. GroupingView throws cfg exception in FF
    By Rainher in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 27 Feb 2008, 6:57 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
  •