1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    3
    Vote Rating
    0
    amerello is on a distinguished road

      0  

    Default TreeStore removeAll() fails

    TreeStore removeAll() fails


    I've noticed some problems when I call removeAll() on a StoreTree item. It fails, because apparently the function removes the most inner children first. Then it checks the parent with hasChildNodes() which was a non-leaf item, but since it has removed all the children already, this function fails. hasChildNodes() is defined as follows:

    Code:
    hasChildNodes : function() {
      return !this.isLeaf() && this.childNodes.length > 0;
    }
    After the children have been deleted, this.childNodes.length no longer exists.

    I have worked around this issue with the following modification:

    Code:
    hasChildNodes : function() {
    return !this.isLeaf() && this.childNodes != null && this.childNodes.length > 0;
    }
    But the removeAll() function should either update the leaf value to true after deleting all the children of a non-leaf node or handle this in other fashion.

    Also I've realized that removeAll() doesn't handle the situation when it's called on an empty TreeStore.

    Could I be doing something wrong or is this a bug?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,637
    Vote Rating
    400
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Try using tree.removeAll() instead of store.removeAll()

    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    3
    Vote Rating
    0
    amerello is on a distinguished road

      0  

    Default


    Hi Scott,
    I'm using it directly on the TreeStore. That's what's failing for me.

  4. #4
    Ext JS Premium Member SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    282
    Vote Rating
    6
    SebTardif is on a distinguished road

      1  

    Default


    Quote Originally Posted by amerello View Post
    Hi Scott,
    I'm using it directly on the TreeStore. That's what's failing for me.
    Action about state should be against the store. In Ext JS 4.1, I also see a bug with removeAll against the TreeStore. The root node is not deleted. So any other call to removeAll, like about "replacing" the data will fail, because the call to nodeInterface.destroy removed some expected state. Same logic was working fine in Ext JS 3.4.

    The code of the library in TreeStore is:
    Code:
     removeAll: function() {
            var root = this.getRootNode();
            if (root) {
                root.destroy(true);
            }
            this.fireEvent('clear', this);
        }
    Then in NodeInterface:
    Code:
    destroy : function(silent) {
                        /*
                         * Silent is to be used in a number of cases
                         * 1) When setRoot is called.
                         * 2) When destroy on the tree is called
                         * 3) For destroying child nodes on a node
                         */
                        var me      = this,
                            options = me.destroyOptions,
                            nodes   = me.childNodes,
                            nLen    = nodes.length,
                            n;
    
                        if (silent === true) {
                            me.clear(true);
    
                            for (n = 0; n < nLen; n++) {
                                nodes[n].destroy(true);
                            }
    
                            me.childNodes = null;
                            delete me.destroyOptions;
                            me.callOverridden([options]);
                        } else {
                            me.destroyOptions = silent;
                            // overridden method will be called, since remove will end up calling destroy(true);
                            me.remove(true);
                        }

  5. #5
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,407
    Vote Rating
    6
    stever will become famous soon enough stever will become famous soon enough

      0  

    Default


    Ever figure this one out? There are a lot of places where this fails if you do a store.removeAll() and later a store.reload().

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar