3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.tree.AsyncTreeNode"></div>/**
\r
10 * @class Ext.tree.AsyncTreeNode
\r
11 * @extends Ext.tree.TreeNode
\r
12 * @cfg {TreeLoader} loader A TreeLoader to be used by this node (defaults to the loader defined on the tree)
\r
14 * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
\r
16 Ext.tree.AsyncTreeNode = function(config){
\r
17 this.loaded = config && config.loaded === true;
\r
18 this.loading = false;
\r
19 Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
\r
22 * Fires before this node is loaded, return false to cancel
\r
23 * @param {Node} this This node
\r
25 this.addEvents('beforeload', 'load');
\r
28 * Fires when this node is loaded
\r
29 * @param {Node} this This node
\r
32 * The loader used by this node (defaults to using the tree's defined loader)
\r
37 Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
\r
38 expand : function(deep, anim, callback, scope){
\r
39 if(this.loading){ // if an async load is already running, waiting til it's done
\r
42 if(!this.loading){ // done loading
\r
43 clearInterval(timer);
\r
44 this.expand(deep, anim, callback, scope);
\r
46 }.createDelegate(this);
\r
47 timer = setInterval(f, 200);
\r
51 if(this.fireEvent("beforeload", this) === false){
\r
54 this.loading = true;
\r
55 this.ui.beforeLoad(this);
\r
56 var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
\r
58 loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);
\r
62 Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
\r
66 * Returns true if this node is currently loading
\r
69 isLoading : function(){
\r
70 return this.loading;
\r
73 loadComplete : function(deep, anim, callback, scope){
\r
74 this.loading = false;
\r
76 this.ui.afterLoad(this);
\r
77 this.fireEvent("load", this);
\r
78 this.expand(deep, anim, callback, scope);
\r
82 * Returns true if this node has been loaded
\r
85 isLoaded : function(){
\r
89 hasChildNodes : function(){
\r
90 if(!this.isLeaf() && !this.loaded){
\r
93 return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
\r
98 * Trigger a reload for this node
\r
99 * @param {Function} callback
\r
100 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Node.
\r
102 reload : function(callback, scope){
\r
103 this.collapse(false, false);
\r
104 while(this.firstChild){
\r
105 this.removeChild(this.firstChild).destroy();
\r
107 this.childrenRendered = false;
\r
108 this.loaded = false;
\r
109 if(this.isHiddenRoot()){
\r
110 this.expanded = false;
\r
112 this.expand(false, false, callback, scope);
\r
116 Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;</pre>
\r