3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 <div id="cls-Ext.tree.AsyncTreeNode"></div>/**
16 * @class Ext.tree.AsyncTreeNode
17 * @extends Ext.tree.TreeNode
18 * @cfg {TreeLoader} loader A TreeLoader to be used by this node (defaults to the loader defined on the tree)
20 * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
22 Ext.tree.AsyncTreeNode = function(config){
23 this.loaded = config && config.loaded === true;
25 Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
28 * Fires before this node is loaded, return false to cancel
29 * @param {Node} this This node
31 this.addEvents('beforeload', 'load');
34 * Fires when this node is loaded
35 * @param {Node} this This node
38 * The loader used by this node (defaults to using the tree's defined loader)
43 Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
44 expand : function(deep, anim, callback, scope){
45 if(this.loading){ // if an async load is already running, waiting til it's done
48 if(!this.loading){ // done loading
50 this.expand(deep, anim, callback, scope);
52 }.createDelegate(this);
53 timer = setInterval(f, 200);
57 if(this.fireEvent("beforeload", this) === false){
61 this.ui.beforeLoad(this);
62 var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
64 loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);
68 Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
72 * Returns true if this node is currently loading
75 isLoading : function(){
79 loadComplete : function(deep, anim, callback, scope){
82 this.ui.afterLoad(this);
83 this.fireEvent("load", this);
84 this.expand(deep, anim, callback, scope);
88 * Returns true if this node has been loaded
91 isLoaded : function(){
95 hasChildNodes : function(){
96 if(!this.isLeaf() && !this.loaded){
99 return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
104 * Trigger a reload for this node
105 * @param {Function} callback
106 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Node.
108 reload : function(callback, scope){
109 this.collapse(false, false);
110 while(this.firstChild){
111 this.removeChild(this.firstChild).destroy();
113 this.childrenRendered = false;
115 if(this.isHiddenRoot()){
116 this.expanded = false;
118 this.expand(false, false, callback, scope);
122 Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;</pre>