3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.tree.AsyncTreeNode"></div>/**
\r
9 * @class Ext.tree.AsyncTreeNode
\r
10 * @extends Ext.tree.TreeNode
\r
11 * @cfg {TreeLoader} loader A TreeLoader to be used by this node (defaults to the loader defined on the tree)
\r
13 * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
\r
15 Ext.tree.AsyncTreeNode = function(config){
\r
16 this.loaded = config && config.loaded === true;
\r
17 this.loading = false;
\r
18 Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
\r
21 * Fires before this node is loaded, return false to cancel
\r
22 * @param {Node} this This node
\r
24 this.addEvents('beforeload', 'load');
\r
27 * Fires when this node is loaded
\r
28 * @param {Node} this This node
\r
31 * The loader used by this node (defaults to using the tree's defined loader)
\r
36 Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
\r
37 expand : function(deep, anim, callback, scope){
\r
38 if(this.loading){ // if an async load is already running, waiting til it's done
\r
41 if(!this.loading){ // done loading
\r
42 clearInterval(timer);
\r
43 this.expand(deep, anim, callback, scope);
\r
45 }.createDelegate(this);
\r
46 timer = setInterval(f, 200);
\r
50 if(this.fireEvent("beforeload", this) === false){
\r
53 this.loading = true;
\r
54 this.ui.beforeLoad(this);
\r
55 var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
\r
57 loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);
\r
61 Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
\r
65 * Returns true if this node is currently loading
\r
68 isLoading : function(){
\r
69 return this.loading;
\r
72 loadComplete : function(deep, anim, callback, scope){
\r
73 this.loading = false;
\r
75 this.ui.afterLoad(this);
\r
76 this.fireEvent("load", this);
\r
77 this.expand(deep, anim, callback, scope);
\r
81 * Returns true if this node has been loaded
\r
84 isLoaded : function(){
\r
88 hasChildNodes : function(){
\r
89 if(!this.isLeaf() && !this.loaded){
\r
92 return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
\r
97 * Trigger a reload for this node
\r
98 * @param {Function} callback
\r
99 * @param {Object} scope (optional) The scope in which to execute the callback.
\r
101 reload : function(callback, scope){
\r
102 this.collapse(false, false);
\r
103 while(this.firstChild){
\r
104 this.removeChild(this.firstChild).destroy();
\r
106 this.childrenRendered = false;
\r
107 this.loaded = false;
\r
108 if(this.isHiddenRoot()){
\r
109 this.expanded = false;
\r
111 this.expand(false, false, callback, scope);
\r
115 Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;</pre>
\r