X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/docs/source/TreeNode.html diff --git a/docs/source/TreeNode.html b/docs/source/TreeNode.html index ff390113..c766ccb3 100644 --- a/docs/source/TreeNode.html +++ b/docs/source/TreeNode.html @@ -1,5 +1,6 @@ + The source code @@ -30,13 +31,13 @@ * @cfg {Boolean} draggable True to make this node draggable (defaults to false) * @cfg {Boolean} isTarget False to not allow this node to act as a drop target (defaults to true) * @cfg {Boolean} allowChildren False to not allow this node to have child nodes (defaults to true) - * @cfg {Boolean} editable False to not allow this node to be edited by an (@link Ext.tree.TreeEditor} (defaults to true) + * @cfg {Boolean} editable False to not allow this node to be edited by an {@link Ext.tree.TreeEditor} (defaults to true) * @constructor * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node */ Ext.tree.TreeNode = function(attributes){ attributes = attributes || {}; - if(typeof attributes == "string"){ + if(Ext.isString(attributes)){ attributes = {text: attributes}; } this.childrenRendered = false; @@ -48,7 +49,7 @@ Ext.tree.TreeNode = function(attributes){ this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false; /** - * Read-only. The text for this node. To change it use setText(). + * Read-only. The text for this node. To change it use {@link #setText}. * @type String */ this.text = attributes.text; @@ -71,7 +72,7 @@ Ext.tree.TreeNode = function(attributes){ * @param {String} text The new text * @param {String} oldText The old text */ - "textchange", + 'textchange', /** * @event beforeexpand * Fires before this node is expanded, return false to cancel. @@ -79,7 +80,7 @@ Ext.tree.TreeNode = function(attributes){ * @param {Boolean} deep * @param {Boolean} anim */ - "beforeexpand", + 'beforeexpand', /** * @event beforecollapse * Fires before this node is collapsed, return false to cancel. @@ -87,67 +88,74 @@ Ext.tree.TreeNode = function(attributes){ * @param {Boolean} deep * @param {Boolean} anim */ - "beforecollapse", + 'beforecollapse', /** * @event expand * Fires when this node is expanded * @param {Node} this This node */ - "expand", + 'expand', /** * @event disabledchange * Fires when the disabled status of this node changes * @param {Node} this This node * @param {Boolean} disabled */ - "disabledchange", + 'disabledchange', /** * @event collapse * Fires when this node is collapsed * @param {Node} this This node */ - "collapse", + 'collapse', /** * @event beforeclick * Fires before click processing. Return false to cancel the default action. * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "beforeclick", + 'beforeclick', /** * @event click * Fires when this node is clicked * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "click", + 'click', /** * @event checkchange * Fires when a node with a checkbox's checked property changes * @param {Node} this This node * @param {Boolean} checked */ - "checkchange", + 'checkchange', + /** + * @event beforedblclick + * Fires before double click processing. Return false to cancel the default action. + * @param {Node} this This node + * @param {Ext.EventObject} e The event object + */ + 'beforedblclick', /** * @event dblclick * Fires when this node is double clicked * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "dblclick", + 'dblclick', /** * @event contextmenu * Fires when this node is right clicked * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "contextmenu", + 'contextmenu', /** * @event beforechildrenrendered * Fires right before the child nodes for this node are rendered * @param {Node} this This node */ - "beforechildrenrendered" + 'beforechildrenrendered' ); var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI; @@ -159,7 +167,7 @@ Ext.tree.TreeNode = function(attributes){ this.ui = new uiClass(this); }; Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { - preventHScroll: true, + preventHScroll : true, /** * Returns true if this node is expanded * @return {Boolean} @@ -180,7 +188,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { getLoader : function(){ var owner; - return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : new Ext.tree.TreeLoader()); + return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader())); }, // private override @@ -222,11 +230,11 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { }, // private override - removeChild : function(node){ + removeChild : function(node, destroy){ this.ownerTree.getSelectionModel().unselect(node); Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments); // if it's been rendered remove dom node - if(this.childrenRendered){ + if(node.ui.rendered){ node.ui.remove(); } if(this.childNodes.length < 1){ @@ -242,7 +250,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { // private override insertBefore : function(node, refNode){ - if(!node.render){ + if(!node.render){ node = this.getLoader().createNode(node); } var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode); @@ -259,26 +267,32 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { */ setText : function(text){ var oldText = this.text; - this.text = text; - this.attributes.text = text; + this.text = this.attributes.text = text; if(this.rendered){ // event without subscribing this.ui.onTextChange(this, text, oldText); } - this.fireEvent("textchange", this, text, oldText); + this.fireEvent('textchange', this, text, oldText); }, /** * Triggers selection of this node */ select : function(){ - this.getOwnerTree().getSelectionModel().select(this); + var t = this.getOwnerTree(); + if(t){ + t.getSelectionModel().select(this); + } }, /** * Triggers deselection of this node + * @param {Boolean} silent (optional) True to stop selection change events from firing. */ - unselect : function(){ - this.getOwnerTree().getSelectionModel().unselect(this); + unselect : function(silent){ + var t = this.getOwnerTree(); + if(t){ + t.getSelectionModel().unselect(this, silent); + } }, /** @@ -286,7 +300,8 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * @return {Boolean} */ isSelected : function(){ - return this.getOwnerTree().getSelectionModel().isSelected(this); + var t = this.getOwnerTree(); + return t ? t.getSelectionModel().isSelected(this) : false; }, /** @@ -296,11 +311,11 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * @param {Function} callback (optional) A callback to be called when * expanding this node completes (does not wait for deep expand to complete). * Called with 1 parameter, this node. - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this TreeNode. */ expand : function(deep, anim, callback, scope){ if(!this.expanded){ - if(this.fireEvent("beforeexpand", this, deep, anim) === false){ + if(this.fireEvent('beforeexpand', this, deep, anim) === false){ return; } if(!this.childrenRendered){ @@ -309,7 +324,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { this.expanded = true; if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){ this.ui.animExpand(function(){ - this.fireEvent("expand", this); + this.fireEvent('expand', this); this.runCallback(callback, scope || this, [this]); if(deep === true){ this.expandChildNodes(true); @@ -318,7 +333,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { return; }else{ this.ui.expand(); - this.fireEvent("expand", this); + this.fireEvent('expand', this); this.runCallback(callback, scope || this, [this]); } }else{ @@ -328,8 +343,8 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { this.expandChildNodes(true); } }, - - runCallback: function(cb, scope, args){ + + runCallback : function(cb, scope, args){ if(Ext.isFunction(cb)){ cb.apply(scope, args); } @@ -346,17 +361,17 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * @param {Function} callback (optional) A callback to be called when * expanding this node completes (does not wait for deep expand to complete). * Called with 1 parameter, this node. - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this TreeNode. */ collapse : function(deep, anim, callback, scope){ if(this.expanded && !this.isHiddenRoot()){ - if(this.fireEvent("beforecollapse", this, deep, anim) === false){ + if(this.fireEvent('beforecollapse', this, deep, anim) === false){ return; } this.expanded = false; if((this.getOwnerTree().animate && anim !== false) || anim){ this.ui.animCollapse(function(){ - this.fireEvent("collapse", this); + this.fireEvent('collapse', this); this.runCallback(callback, scope || this, [this]); if(deep === true){ this.collapseChildNodes(true); @@ -365,7 +380,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { return; }else{ this.ui.collapse(); - this.fireEvent("collapse", this); + this.fireEvent('collapse', this); this.runCallback(callback, scope || this, [this]); } }else if(!this.expanded){ @@ -409,7 +424,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * Ensures all parent nodes are expanded, and if necessary, scrolls * the node into view. * @param {Function} callback (optional) A function to call when the node has been made visible. - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this TreeNode. */ ensureVisible : function(callback, scope){ var tree = this.getOwnerTree(); @@ -451,7 +466,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { if(this.rendered && this.ui.onDisableChange){ // event without subscribing this.ui.onDisableChange(this, true); } - this.fireEvent("disabledchange", this, true); + this.fireEvent('disabledchange', this, true); }, /** @@ -462,13 +477,13 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { if(this.rendered && this.ui.onDisableChange){ // event without subscribing this.ui.onDisableChange(this, false); } - this.fireEvent("disabledchange", this, false); + this.fireEvent('disabledchange', this, false); }, // private renderChildren : function(suppressEvent){ if(suppressEvent !== false){ - this.fireEvent("beforechildrenrendered", this); + this.fireEvent('beforechildrenrendered', this); } var cs = this.childNodes; for(var i = 0, len = cs.length; i < len; i++){ @@ -527,19 +542,14 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { }, destroy : function(){ - if(this.childNodes){ - for(var i = 0,l = this.childNodes.length; i < l; i++){ - this.childNodes[i].destroy(); - } - this.childNodes = null; - } - if(this.ui.destroy){ - this.ui.destroy(); - } + this.unselect(true); + Ext.tree.TreeNode.superclass.destroy.call(this); + Ext.destroy(this.ui, this.loader); + this.ui = this.loader = null; }, - + // private - onIdChange: function(id){ + onIdChange : function(id){ this.ui.onIdChange(id); } });