X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/src/widgets/tree/TreePanel.js?ds=sidebyside diff --git a/src/widgets/tree/TreePanel.js b/src/widgets/tree/TreePanel.js index 54000d43..9099ccff 100644 --- a/src/widgets/tree/TreePanel.js +++ b/src/widgets/tree/TreePanel.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.0.3 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.1.1 + * Copyright(c) 2006-2010 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ @@ -118,18 +118,19 @@ new Ext.Viewport({ */ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { rootVisible : true, - animate: Ext.enableFx, + animate : Ext.enableFx, lines : true, enableDD : false, hlDrop : Ext.enableFx, - pathSeparator: "/", - + pathSeparator : '/', + /** * @cfg {Array} bubbleEvents *

An array of events that, when fired, should be bubbled to any parent container. - * Defaults to ['add', 'remove']. + * See {@link Ext.util.Observable#enableBubble}. + * Defaults to []. */ - bubbleEvents: [], + bubbleEvents : [], initComponent : function(){ Ext.tree.TreePanel.superclass.initComponent.call(this); @@ -145,7 +146,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { dataUrl: this.dataUrl, requestMethod: this.requestMethod }); - }else if(typeof l == 'object' && !l.load){ + }else if(Ext.isObject(l) && !l.load){ l = new Ext.tree.TreeLoader(l); } this.loader = l; @@ -174,7 +175,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} node The newly appended node * @param {Number} index The index of the newly appended node */ - "append", + 'append', /** * @event remove * Fires when a child node is removed from a node in this tree. @@ -182,7 +183,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} parent The parent node * @param {Node} node The child node removed */ - "remove", + 'remove', /** * @event movenode * Fires when a node is moved to a new location in the tree @@ -192,7 +193,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} newParent The new parent of this node * @param {Number} index The index it was moved to */ - "movenode", + 'movenode', /** * @event insert * Fires when a new child node is inserted in a node in this tree. @@ -201,7 +202,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} node The child node inserted * @param {Node} refNode The child node the node was inserted before */ - "insert", + 'insert', /** * @event beforeappend * Fires before a new child is appended to a node in this tree, return false to cancel the append. @@ -209,7 +210,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} parent The parent node * @param {Node} node The child node to be appended */ - "beforeappend", + 'beforeappend', /** * @event beforeremove * Fires before a child is removed from a node in this tree, return false to cancel the remove. @@ -217,7 +218,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} parent The parent node * @param {Node} node The child node to be removed */ - "beforeremove", + 'beforeremove', /** * @event beforemovenode * Fires before a node is moved to a new location in the tree. Return false to cancel the move. @@ -227,7 +228,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} newParent The new parent the node is moving to * @param {Number} index The index it is being moved to */ - "beforemovenode", + 'beforemovenode', /** * @event beforeinsert * Fires before a new child is inserted in a node in this tree, return false to cancel the insert. @@ -236,20 +237,20 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} node The child node to be inserted * @param {Node} refNode The child node the node is being inserted before */ - "beforeinsert", + 'beforeinsert', /** * @event beforeload * Fires before a node is loaded, return false to cancel * @param {Node} node The node being loaded */ - "beforeload", + 'beforeload', /** * @event load * Fires when a node is loaded * @param {Node} node The node that was loaded */ - "load", + 'load', /** * @event textchange * Fires when the text for a node is changed @@ -257,7 +258,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {String} text The new text * @param {String} oldText The old text */ - "textchange", + 'textchange', /** * @event beforeexpandnode * Fires before a node is expanded, return false to cancel. @@ -265,7 +266,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Boolean} deep * @param {Boolean} anim */ - "beforeexpandnode", + 'beforeexpandnode', /** * @event beforecollapsenode * Fires before a node is collapsed, return false to cancel. @@ -273,61 +274,75 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Boolean} deep * @param {Boolean} anim */ - "beforecollapsenode", + 'beforecollapsenode', /** * @event expandnode * Fires when a node is expanded * @param {Node} node The node */ - "expandnode", + 'expandnode', /** * @event disabledchange * Fires when the disabled status of a node changes * @param {Node} node The node * @param {Boolean} disabled */ - "disabledchange", + 'disabledchange', /** * @event collapsenode * Fires when a node is collapsed * @param {Node} node The node */ - "collapsenode", + 'collapsenode', /** * @event beforeclick * Fires before click processing on a node. Return false to cancel the default action. * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "beforeclick", + 'beforeclick', /** * @event click * Fires when a node is clicked * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "click", + 'click', + /** + * @event containerclick + * Fires when the tree container is clicked + * @param {Tree} this + * @param {Ext.EventObject} e The event object + */ + 'containerclick', /** * @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 on a node. Return false to cancel the default action. * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "beforedblclick", + 'beforedblclick', /** * @event dblclick * Fires when a node is double clicked * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "dblclick", + 'dblclick', + /** + * @event containerdblclick + * Fires when the tree container is double clicked + * @param {Tree} this + * @param {Ext.EventObject} e The event object + */ + 'containerdblclick', /** * @event contextmenu * Fires when a node is right clicked. To display a context menu in response to this @@ -375,13 +390,20 @@ new Ext.tree.TreePanel({ * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "contextmenu", + 'contextmenu', + /** + * @event containercontextmenu + * Fires when the tree container is right clicked + * @param {Tree} this + * @param {Ext.EventObject} e The event object + */ + 'containercontextmenu', /** * @event beforechildrenrendered * Fires right before the child nodes for a node are rendered * @param {Node} node The node */ - "beforechildrenrendered", + 'beforechildrenrendered', /** * @event startdrag * Fires when a node starts being dragged @@ -389,7 +411,7 @@ new Ext.tree.TreePanel({ * @param {Ext.tree.TreeNode} node * @param {event} e The raw browser event */ - "startdrag", + 'startdrag', /** * @event enddrag * Fires when a drag operation is complete @@ -397,7 +419,7 @@ new Ext.tree.TreePanel({ * @param {Ext.tree.TreeNode} node * @param {event} e The raw browser event */ - "enddrag", + 'enddrag', /** * @event dragdrop * Fires when a dragged node is dropped on a valid DD target @@ -406,7 +428,7 @@ new Ext.tree.TreePanel({ * @param {DD} dd The dd it was dropped on * @param {event} e The raw browser event */ - "dragdrop", + 'dragdrop', /** * @event beforenodedrop * Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The dropEvent @@ -422,11 +444,11 @@ new Ext.tree.TreePanel({ * to be inserted by setting them on this object. *

  • cancel - Set this to true to cancel the drop.
  • *
  • dropStatus - If the default drop action is cancelled but the drop is valid, setting this to true - * will prevent the animated "repair" from appearing.
  • + * will prevent the animated 'repair' from appearing. * * @param {Object} dropEvent */ - "beforenodedrop", + 'beforenodedrop', /** * @event nodedrop * Fires after a DD object is dropped on a node in this tree. The dropEvent @@ -442,7 +464,7 @@ new Ext.tree.TreePanel({ * * @param {Object} dropEvent */ - "nodedrop", + 'nodedrop', /** * @event nodedragover * Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent @@ -459,10 +481,10 @@ new Ext.tree.TreePanel({ * * @param {Object} dragOverEvent */ - "nodedragover" + 'nodedragover' ); if(this.singleExpand){ - this.on("beforeexpandnode", this.restrictExpand, this); + this.on('beforeexpandnode', this.restrictExpand, this); } }, @@ -503,12 +525,24 @@ new Ext.tree.TreePanel({ var uiP = node.attributes.uiProvider; node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node); } - if (this.innerCt) { - this.innerCt.update(''); - this.afterRender(); + if(this.innerCt){ + this.clearInnerCt(); + this.renderRoot(); } return node; }, + + clearInnerCt : function(){ + this.innerCt.update(''); + }, + + // private + renderRoot : function(){ + this.root.render(); + if(!this.rootVisible){ + this.root.renderChildren(); + } + }, /** * Gets a node in this tree by its id @@ -531,7 +565,7 @@ new Ext.tree.TreePanel({ // private toString : function(){ - return "[Tree"+(this.id?" "+this.id:"")+"]"; + return '[Tree'+(this.id?' '+this.id:'')+']'; }, // private @@ -546,7 +580,7 @@ new Ext.tree.TreePanel({ }, /** - * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. "id") + * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. 'id') * @param {String} attribute (optional) Defaults to null (return the actual nodes) * @param {TreeNode} startNode (optional) The node to start from, defaults to the root * @return {Array} @@ -563,14 +597,6 @@ new Ext.tree.TreePanel({ return r; }, - /** - * Returns the container element for this TreePanel. - * @return {Element} The container element for this TreePanel. - */ - getEl : function(){ - return this.el; - }, - /** * Returns the default {@link Ext.tree.TreeLoader} for this TreePanel. * @return {Ext.tree.TreeLoader} The TreeLoader for this TreePanel. @@ -612,7 +638,7 @@ new Ext.tree.TreePanel({ * (bSuccess, oLastNode) where bSuccess is if the expand was successful and oLastNode is the last node that was expanded. */ expandPath : function(path, attr, callback){ - attr = attr || "id"; + attr = attr || 'id'; var keys = path.split(this.pathSeparator); var curNode = this.root; if(curNode.attributes[attr] != keys[1]){ // invalid root @@ -650,7 +676,7 @@ new Ext.tree.TreePanel({ * (bSuccess, oSelNode) where bSuccess is if the selection was successful and oSelNode is the selected node. */ selectPath : function(path, attr, callback){ - attr = attr || "id"; + attr = attr || 'id'; var keys = path.split(this.pathSeparator), v = keys.pop(); if(keys.length > 1){ @@ -692,9 +718,9 @@ new Ext.tree.TreePanel({ onRender : function(ct, position){ Ext.tree.TreePanel.superclass.onRender.call(this, ct, position); this.el.addClass('x-tree'); - this.innerCt = this.body.createChild({tag:"ul", - cls:"x-tree-root-ct " + - (this.useArrows ? 'x-tree-arrows' : this.lines ? "x-tree-lines" : "x-tree-no-lines")}); + this.innerCt = this.body.createChild({tag:'ul', + cls:'x-tree-root-ct ' + + (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines')}); }, // private @@ -711,7 +737,7 @@ new Ext.tree.TreePanel({ * @type Ext.tree.TreeDropZone */ this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || { - ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true + ddGroup: this.ddGroup || 'TreeDD', appendOnly: this.ddAppendOnly === true }); } if((this.enableDD || this.enableDrag) && !this.dragZone){ @@ -721,7 +747,7 @@ new Ext.tree.TreePanel({ * @type Ext.tree.TreeDragZone */ this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || { - ddGroup: this.ddGroup || "TreeDD", + ddGroup: this.ddGroup || 'TreeDD', scroll: this.ddScroll }); } @@ -731,26 +757,17 @@ new Ext.tree.TreePanel({ // private afterRender : function(){ Ext.tree.TreePanel.superclass.afterRender.call(this); - this.root.render(); - if(!this.rootVisible){ - this.root.renderChildren(); - } + this.renderRoot(); }, - onDestroy : function(){ + beforeDestroy : function(){ if(this.rendered){ - this.body.removeAllListeners(); Ext.dd.ScrollManager.unregister(this.body); - if(this.dropZone){ - this.dropZone.unreg(); - } - if(this.dragZone){ - this.dragZone.unreg(); - } + Ext.destroy(this.dropZone, this.dragZone); } - this.root.destroy(); - this.nodeHash = null; - Ext.tree.TreePanel.superclass.onDestroy.call(this); + Ext.destroy(this.root, this.loader); + this.nodeHash = this.root = this.loader = null; + Ext.tree.TreePanel.superclass.beforeDestroy.call(this); } /** @@ -892,6 +909,15 @@ new Ext.tree.TreePanel({ /** * @cfg {String} contentEl @hide */ + /** + * @cfg {Mixed} data @hide + */ + /** + * @cfg {Mixed} tpl @hide + */ + /** + * @cfg {String} tplWriteMode @hide + */ /** * @cfg {String} disabledClass @hide */