1. #1
    Ext User Jacob's Avatar
    Join Date
    Aug 2007
    Posts
    26
    Vote Rating
    0
    Jacob is on a distinguished road

      0  

    Default How to stop loading animation in AsyncTreeNode

    How to stop loading animation in AsyncTreeNode


    I use AsyncTreeNodes to load an XML string
    The code is right, i mean it does what i expected from it...
    Anyway, the animated icon that shows that my node is loading doesn't stops at the end of my event handler (on the 'expand' event).

    I guess I've got to do something to tell the node that the process is done... But what ?

    Thanks in advance !

  2. #2
    Ext Premium Member BernardChhun's Avatar
    Join Date
    Mar 2007
    Location
    Quebec, Canada
    Posts
    831
    Vote Rating
    2
    BernardChhun will become famous soon enough

      0  

    Default


    hey lumpied Jacob,

    actually you don't have to do anything. it usually stops by itself.

  3. #3
    Ext User
    Join Date
    Aug 2007
    Posts
    59
    Vote Rating
    0
    Barius is on a distinguished road

      0  

    Default


    Did you specify the 'leaf' attribute (boolean) for each of your nodes? If you don't specify it then Ext will try to load the node like a folder which causes the icon to show as 'loading' forever.

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    36
    Vote Rating
    0
    John Holmes is on a distinguished road

      0  

    Default


    Hi. I have the same problem.

    Im currently load nodes in TreePanel without using a TreeLoader. The tree panel have inside a fixed struct formed by a mix of some TreeNode and AsyncTreeNoe like this

    + Group (TreeNode)
    |
    ---- + Users (AsyncTreeNode)
    ---- + Rules (AsyncTreeNode)

    Setting the "expand" event of the AsyncTreeNodes with my own childNodes data load function, i can fill the Users or Rules nodes with all childNodes i want, but i'm not able to stop loading gif animation of the AsyncTreeNodes.

    how to do this?

    tia

  5. #5
    Ext User
    Join Date
    Jul 2007
    Posts
    36
    Vote Rating
    0
    John Holmes is on a distinguished road

      0  

    Default


    Eureka!

    Don't know if it is right but firebugging i'have found that AsyncTreeNodes have a loadComplete() method.

    use this to stop the loading gif animation!

    node.loadComplete();

    --- 5 minutes later ---

    Forget about that. this way works only the first time you expand the node. Once you collapse the node and then re-expand, seem that the expand event will be rised infinitely...

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Add a "loadexception" listener to your TreeLoader. It could be that there's some error in the remote loading process.

  7. #7
    Ext User
    Join Date
    Jul 2007
    Posts
    36
    Vote Rating
    0
    John Holmes is on a distinguished road

      0  

    Default


    Quote Originally Posted by Animal View Post
    Add a "loadexception" listener to your TreeLoader. It could be that there's some error in the remote loading process.
    Ok my english is not so good, but probably you have to read posts carefully...

    again...

    Im currently load nodes in TreePanel without using a TreeLoader.

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The advice was for Jacob, but...

    In your case, I think it's a bug in AsyncTreeNode.

    Code is

    Code:
        expand : function(deep, anim, callback){
            if(this.loading){ // if an async load is already running, waiting til it's done
                var timer;
                var f = function(){
                    if(!this.loading){ // done loading
                        clearInterval(timer);
                        this.expand(deep, anim, callback);
                    }
                }.createDelegate(this);
                timer = setInterval(f, 200);
                return;
            }
            if(!this.loaded){
                if(this.fireEvent("beforeload", this) === false){
                    return;
                }
                this.loading = true;
                this.ui.beforeLoad(this);
                var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
                if(loader){
                    loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback]));
                    return;
                }
            }
            Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback);
        },
    It should IMHO, be:

    Code:
        expand : function(deep, anim, callback){
            if(this.loading){ // if an async load is already running, waiting til it's done
                var timer;
                var f = function(){
                    if(!this.loading){ // done loading
                        clearInterval(timer);
                        this.expand(deep, anim, callback);
                    }
                }.createDelegate(this);
                timer = setInterval(f, 200);
                return;
            }
            if(!this.loaded){
                if(this.fireEvent("beforeload", this) === false){
                    return;
                }
                var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
                if(loader){
                    this.loading = true;
                    this.ui.beforeLoad(this);
                    loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback]));
                    return;
                }
            }
            Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback);
        },
    Add that to your overrides and see if it works. If it does, you might want to submit a bug report.

  9. #9
    Ext User
    Join Date
    Jul 2007
    Posts
    36
    Vote Rating
    0
    John Holmes is on a distinguished road

      0  

    Default


    Sorry i believe you answerto me...

    Thx for the help.

  10. #10
    Ext User
    Join Date
    Jul 2007
    Posts
    36
    Vote Rating
    0
    John Holmes is on a distinguished road

      0  

    Default


    Here we are

    I'm not sure Animal, but what you write will not correct the behaviour becuase my AsynTreeNode have no loader referenced. The code inside the

    Code:
    if(loader) {
    ...
    }
    is always ignored.

    What i have done:

    I have set up a load function in the "expand" event of the AsyncTreeNode all works fine. To stop the loading animation just add a node.loadComplete() call. Here an example

    Code:
    var node = new Ext.tree.AsyncTreeNode({...})  // NO TreeLoader used
    
    function loadChildNodes() {
      
       node = getSelectedNodeFromTree(tree); // tree is global
    
       // Populate node with childNodes
       ...
       ...
    
       node.loadComplete();
    }
    
    node.on("expand",
    
      function(node) {
         node.select();
         loadChildNodes();
      }, this);
    The example above works fine except you collapse and than expand the AsyncTreeNode again. I think i have to add a node.reload() call in the loadChildNodes() function to reset the AsyncTreeNode in reload status. Something like that

    Code:
    function loadChildNodes() {
      
       node = getSelectedNodeFromTree(tree); // tree is global
      
       if(node.isLoaded()) node.reload();
    
       // Populate node with childNodes
       ...
       ...
    
       node.loadComplete();
    }
    The problem is that the node.reload() call rethrow the "expand" event of the AsynTreeNode so tha app fall in a infinite loop.

    hope now it's clear

    tia

    Francesco

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