4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
13 * @class Roo.tree.AsyncTreeNode
14 * @extends Roo.tree.TreeNode
15 * @cfg {TreeLoader} loader A TreeLoader to be used by this node (defaults to the loader defined on the tree)
17 * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
19 Roo.tree.AsyncTreeNode = function(config){
22 Roo.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
25 * Fires before this node is loaded, return false to cancel
26 * @param {Node} this This node
28 this.addEvents({'beforeload':true, 'load': true});
31 * Fires when this node is loaded
32 * @param {Node} this This node
35 * The loader used by this node (defaults to using the tree's defined loader)
40 Roo.extend(Roo.tree.AsyncTreeNode, Roo.tree.TreeNode, {
41 expand : function(deep, anim, callback){
42 if(this.loading){ // if an async load is already running, waiting til it's done
45 if(!this.loading){ // done loading
47 this.expand(deep, anim, callback);
49 }.createDelegate(this);
50 timer = setInterval(f, 200);
54 if(this.fireEvent("beforeload", this) === false){
58 this.ui.beforeLoad(this);
59 var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
61 loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback]));
65 Roo.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback);
69 * Returns true if this node is currently loading
72 isLoading : function(){
76 loadComplete : function(deep, anim, callback){
79 this.ui.afterLoad(this);
80 this.fireEvent("load", this);
81 this.expand(deep, anim, callback);
85 * Returns true if this node has been loaded
88 isLoaded : function(){
92 hasChildNodes : function(){
93 if(!this.isLeaf() && !this.loaded){
96 return Roo.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
101 * Trigger a reload for this node
102 * @param {Function} callback
104 reload : function(callback){
105 this.collapse(false, false);
106 while(this.firstChild){
107 this.removeChild(this.firstChild);
109 this.childrenRendered = false;
111 if(this.isHiddenRoot()){
112 this.expanded = false;
114 this.expand(false, false, callback);