Sencha Documentation

The TreePanel provides tree-structured UI representation of tree-structured data.

TreeNodes added to the TreePanel may each contain metadata used by your application in their attributes property.

A TreePanel must have a root node before it is rendered. This may either be specified using the root config option, or using the setRootNode method.

An example of tree rendered to an existing div:

var tree = new Ext.tree.TreePanel({
    renderTo: 'tree-div',
    useArrows: true,
    autoScroll: true,
    animate: true,
    enableDD: true,
    containerScroll: true,
    border: false,
    // auto create TreeLoader
    dataUrl: 'get-nodes.php',

    root: {
        nodeType: 'async',
        text: 'Ext JS',
        draggable: false,
        id: 'source'
    }
});

tree.getRootNode().expand();

The example above would work with a data packet similar to this:

[{
    "text": "adapter",
    "id": "source\/adapter",
    "cls": "folder"
}, {
    "text": "dd",
    "id": "source\/dd",
    "cls": "folder"
}, {
    "text": "debug.js",
    "id": "source\/debug.js",
    "leaf": true,
    "cls": "file"
}]

An example of tree within a Viewport:

new Ext.Viewport({
    layout: 'border',
    items: [{
        region: 'west',
        collapsible: true,
        title: 'Navigation',
        xtype: 'treepanel',
        width: 200,
        autoScroll: true,
        split: true,
        loader: new Ext.tree.TreeLoader(),
        root: new Ext.tree.AsyncTreeNode({
            expanded: true,
            children: [{
                text: 'Menu Option 1',
                leaf: true
            }, {
                text: 'Menu Option 2',
                leaf: true
            }, {
                text: 'Menu Option 3',
                leaf: true
            }]
        }),
        rootVisible: false,
        listeners: {
            click: function(n) {
                Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');
            }
        }
    }, {
        region: 'center',
        xtype: 'tabpanel',
        // remaining code not shown ...
    }]
});

Config Options

 
animCollapse : Boolean
true to animate the transition when the panel is collapsed, false to skip the animation (defaults to true if the Ext....
true to animate the transition when the panel is collapsed, false to skip the animation (defaults to true if the Ext.Fx class is available, otherwise false). May also be specified as the animation duration in milliseconds.
 
animate : Boolean
true to enable animated expand/collapse (defaults to the value of Ext.enableFx)
true to enable animated expand/collapse (defaults to the value of Ext.enableFx)
 
baseCls : String
The base CSS class to apply to this panel's element (defaults to 'x-panel').
The base CSS class to apply to this panel's element (defaults to 'x-panel').
 
bodyBorder : Number/Boolean
A shortcut for setting a border style on the body element. The value can either be a number to be applied to all side...
A shortcut for setting a border style on the body element. The value can either be a number to be applied to all sides, or a normal css string describing borders. Defaults to undefined.
 
bodyMargin : Number/Boolean
A shortcut for setting a margin style on the body element. The value can either be a number to be applied to all side...
A shortcut for setting a margin style on the body element. The value can either be a number to be applied to all sides, or a normal css string describing margins. Defaults to undefined.
 
bodyPadding : Number/Boolean
A shortcut for setting a padding style on the body element. The value can either be a number to be applied to all sid...
A shortcut for setting a padding style on the body element. The value can either be a number to be applied to all sides, or a normal css string describing padding. Defaults to undefined.
 
bubbleEvents : Array
An array of events that, when fired, should be bubbled to any parent container. See Ext.util.Observable.enableBubble....

An array of events that, when fired, should be bubbled to any parent container. See Ext.util.Observable.enableBubble. Defaults to [].

 
closable : Boolean
True to display the 'close' tool button and allow the user to close the window, false to hide the button and disallow...

True to display the 'close' tool button and allow the user to close the window, false to hide the button and disallow closing the window (defaults to false).

By default, when close is requested by clicking the close button in the header, the close method will be called. This will destroy the Panel and its content meaning that it may not be reused.

To make closing a Panel hide the Panel so that it may be reused, set closeAction to 'hide'.

 
closeAction : String
The action to take when the close header tool is clicked: <div class="mdetail-params"> 'close' : Default<div class="s...

The action to take when the close header tool is clicked:

  • 'close' : Default
    remove the window from the DOM and destroy it and all descendant Components. The window will not be available to be redisplayed via the show method.
  • 'hide' :
    hide the window by setting visibility to hidden and applying negative offsets. The window will be available to be redisplayed via the show method.

Note: This behavior has changed! setting *does* affect the close method which will invoke the approriate closeAction.

 
The direction to collapse the Panel when the toggle button is clicked. Defaults to the headerPosition Important: This...

The direction to collapse the Panel when the toggle button is clicked.

Defaults to the headerPosition

Important: This config is ignored for collapsible Panels which are direct child items of a border layout.

Specify as 'top', 'bottom', 'left' or 'right'.

 
collapseFirst : Boolean
true to make sure the collapse/expand toggle button always renders first (to the left of) any other tools in the pane...
true to make sure the collapse/expand toggle button always renders first (to the left of) any other tools in the panel's title bar, false to render it last (defaults to true).
 
collapseMode : String
Important: this config is only effective for collapsible Panels which are direct child items of a border layout. When...

Important: this config is only effective for collapsible Panels which are direct child items of a border layout.

When not a direct child item of a border layout, then the Panel's header remains visible, and the body is collapsed to zero dimensions. If the Panel has no header, then a new header (orientated correctly depending on the collapseDirection) will be inserted to show a the title and a re-expand tool.

When a child item of a border layout, this config has two options:

  • alt : Default.
    When collapsed, a placeholder Container is injected into the layout to represent the Panel and to provide a UI with a Tool to allow the user to re-expand the Panel.
  • header :
    The Panel collapses to leave a header visible as when not inside a border layout.

 
collapsed : Boolean
true to render the panel collapsed, false to render it expanded (defaults to false).
true to render the panel collapsed, false to render it expanded (defaults to false).
 
collapsedCls : String
A CSS class to add to the panel's element after it has been collapsed (defaults to 'x-panel-collapsed').
A CSS class to add to the panel's element after it has been collapsed (defaults to 'x-panel-collapsed').
 
collapsible : Boolean
True to make the panel collapsible and have an expand/collapse toggle Tool added into the header tool button area. Fa...

True to make the panel collapsible and have an expand/collapse toggle Tool added into the header tool button area. False to keep the panel sized either statically, or by an owning layout manager, with no toggle Tool (defaults to false).

See collapseMode and collapseDirection
 
containerScroll : Boolean
true to register this container with ScrollManager
true to register this container with ScrollManager
 
ddAppendOnly : Boolean
true if the tree should only allow append drops (use for trees which are sorted)
true if the tree should only allow append drops (use for trees which are sorted)
 
ddGroup : String
The DD group this TreePanel belongs to
The DD group this TreePanel belongs to
 
ddScroll : Boolean
true to enable body scrolling
true to enable body scrolling
 
dockedItems : Object/Array
A component or series of components to be added as docked items to this panel. The docked items can be docked to eith...
A component or series of components to be added as docked items to this panel. The docked items can be docked to either the top, right, left or bottom of a panel. This is typically used for things like toolbars or tab bars:
var panel = new Ext.Panel({
    fullscreen: true,
    dockedItems: [{
        xtype: 'toolbar',
        dock: 'top',
        items: [{
            text: 'Docked to the bottom'
        }]
    }]
});
 
dragConfig : Object
Custom config to pass to the Ext.tree.TreeDragZone instance
Custom config to pass to the Ext.tree.TreeDragZone instance
 
dropConfig : Object
Custom config to pass to the Ext.tree.TreeDropZone instance
Custom config to pass to the Ext.tree.TreeDropZone instance
 
enableDD : Boolean
true to enable drag and drop
true to enable drag and drop
 
enableDrag : Boolean
true to enable just drag
true to enable just drag
 
enableDrop : Boolean
true to enable just drop
true to enable just drop
 
floatable : Boolean
Important: This config is only effective for collapsible Panels which are direct child items of a border layout. true...

Important: This config is only effective for collapsible Panels which are direct child items of a border layout.

true to allow clicking a collapsed Panel's placeHolder to display the Panel floated above the layout, false to force the user to fully expand a collapsed region by clicking the expand button to see it again (defaults to true).
 
frame : Boolean
True to apply a frame to the panel.
True to apply a frame to the panel.
 
Specify as 'top', 'bottom', 'left' or 'right'. Defaults to 'top'.
Specify as 'top', 'bottom', 'left' or 'right'. Defaults to 'top'.
 
true to hide the expand/collapse toggle button when collapsible == true, false to display it (defaults to false).
true to hide the expand/collapse toggle button when collapsible == true, false to display it (defaults to false).
 
hlColor : String
The color of the node highlight (defaults to 'C3DAF9')
The color of the node highlight (defaults to 'C3DAF9')
 
hlDrop : Boolean
false to disable node highlight on drop (defaults to the value of Ext.enableFx)
false to disable node highlight on drop (defaults to the value of Ext.enableFx)
 
lines : Boolean
false to disable tree lines (defaults to true)
false to disable tree lines (defaults to true)
 
loader : Ext.tree.TreeLoader
A Ext.tree.TreeLoader for use with this TreePanel
A Ext.tree.TreeLoader for use with this TreePanel
 
Minimum width of all form buttons in pixels (defaults to 75). If set, this will be used as the default value for the ...
Minimum width of all form buttons in pixels (defaults to 75). If set, this will be used as the default value for the Ext.form.Button.minWidth config of each Button added to the footer toolbar. Will be ignored for buttons that have this value configured some other way, e.g. in their own config object or via the defaults config of their parent container.
 
pathSeparator : String
The token used to separate sub-paths in path strings (defaults to '/')
The token used to separate sub-paths in path strings (defaults to '/')
 
placeHolder : Mixed
Important: This config is only effective for collapsible Panels which are direct child items of a border layout when ...

Important: This config is only effective for collapsible Panels which are direct child items of a border layout when using the default 'alt' collapseMode.

b>Optional. A Component (or config object for a Component) to show in place of this Panel when this Panel is collapsed by a border layout. Defaults to a generated Header containing a Tool to re-expand the Panel.

 
preventHeader : Boolean
Prevent a Header from being created and shown. Defaults to false.
Prevent a Header from being created and shown. Defaults to false.
 
requestMethod : String
The HTTP request method for loading data (defaults to the value of Ext.Ajax.method).
The HTTP request method for loading data (defaults to the value of Ext.Ajax.method).
 
root : Ext.tree.TreeNode
The root node for the tree.
The root node for the tree.
 
rootVisible : Boolean
false to hide the root node (defaults to true)
false to hide the root node (defaults to true)
 
selModel : Object
A tree selection model to use with this TreePanel (defaults to an Ext.tree.DefaultSelectionModel)
A tree selection model to use with this TreePanel (defaults to an Ext.tree.DefaultSelectionModel)
 
singleExpand : Boolean
true if only 1 node per branch may be expanded
true if only 1 node per branch may be expanded
 
titleCollapse : Boolean
true to allow expanding and collapsing the panel (when collapsible = true) by clicking anywhere in the header bar, fa...
true to allow expanding and collapsing the panel (when collapsible = true) by clicking anywhere in the header bar, false) to allow it only by clicking to tool button (defaults to false)).
 
trackMouseOver : Boolean
false to disable mouse over highlighting
false to disable mouse over highlighting
 
useArrows : Boolean
true to use Vista-style arrows in the tree (defaults to false)
true to use Vista-style arrows in the tree (defaults to false)

Properties

 
dd : Ext.dd.DragSource.
If this Panel is configured draggable, this property will contain an instance of Ext.dd.DragSource which handles drag...

If this Panel is configured draggable, this property will contain an instance of Ext.dd.DragSource which handles dragging the Panel.

The developer must provide implementations of the abstract methods of Ext.dd.DragSource in order to supply behaviour for each stage of the drag/drop process. See draggable.
 
dragZone : Ext.tree.TreeDragZone
The dragZone used by this tree if drag is enabled (see enableDD or enableDrag)
The dragZone used by this tree if drag is enabled (see enableDD or enableDrag)
 
dropZone : Ext.tree.TreeDropZone
The dropZone used by this tree if drop is enabled (see enableDD or enableDrop)
The dropZone used by this tree if drop is enabled (see enableDD or enableDrop)
 
root : Ext.tree.TreeNode
The root node of this tree.
The root node of this tree.

Methods

 
addDocked( Object/Array component., [Number pos] ) : Void
Adds docked item(s) to the panel.
Adds docked item(s) to the panel.

Parameters

  • component. : Object/Array
    The Component or array of components to add. The components must include a 'dock' parameter on each component to indicate where it should be docked ('top', 'right', 'bottom', 'left').
  • pos : Number
    (optional) The index at which the Component will be added

Returns

  • Void
 
close : Void
Closes the Panel. By default, this method, removes it from the DOM, destroys the Panel object and all its descendant ...

Closes the Panel. By default, this method, removes it from the DOM, destroys the Panel object and all its descendant Components. The beforeclose event is fired before the close happens and will cancel the close action if it returns false.

Note: This method is not affected by the closeAction setting which only affects the action triggered when clicking the 'close' tool in the header. To hide the Panel without destroying it, call hide.

 
collapse( Number direction., Boolean animate ) : Ext.panel.Panel
Collapses the panel body so that the body becomes hidden. Docked Components parallel to the border towards which the ...
Collapses the panel body so that the body becomes hidden. Docked Components parallel to the border towards which the collapse takes place will remain visible. Fires the beforecollapse event which will cancel the collapse action if it returns false.

Parameters

  • direction. : Number
    The direction to collapse towards. Must be one of
    • Ext.Component.DIRECTION_TOP
    • Ext.Component.DIRECTION_RIGHT
    • Ext.Component.DIRECTION_BOTTOM
    • Ext.Component.DIRECTION_LEFT
  • animate : Boolean
    True to animate the transition, else false (defaults to the value of the animCollapse panel config)

Returns

  • Ext.panel.Panel   this
 
Collapse all nodes
Collapse all nodes
 
expand( Boolean animate ) : Ext.panel.Panel
Expands the panel body so that it becomes visible. Fires the beforeexpand event which will cancel the expand action ...
Expands the panel body so that it becomes visible. Fires the beforeexpand event which will cancel the expand action if it returns false.

Parameters

  • animate : Boolean
    True to animate the transition, else false (defaults to the value of the animCollapse panel config)

Returns

  • Ext.panel.Panel   this
 
expandAll : Void
Expand all nodes
Expand all nodes
 
expandPath( String path, [String attr], [Function callback] ) : Void
Expands a specified path in this TreePanel. A path can be retrieved from a node with Ext.data.Node.getPath
Expands a specified path in this TreePanel. A path can be retrieved from a node with Ext.data.Node.getPath

Parameters

  • path : String
  • attr : String
    (optional) The attribute used in the path (see Ext.data.Node.getPath for more info)
  • callback : Function
    (optional) The callback to call when the expand is complete. The callback will be called with (bSuccess, oLastNode) where bSuccess is if the expand was successful and oLastNode is the last node that was expanded.

Returns

  • Void
 
getChecked( [String attribute], [TreeNode startNode] ) : Array
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')

Parameters

  • attribute : String
    (optional) Defaults to null (return the actual nodes)
  • startNode : TreeNode
    (optional) The node to start from, defaults to the root

Returns

  • Array   undefined
 
getDockedComponent( String/Number comp ) : Ext.Component
Finds a docked component by id, itemId or position
Finds a docked component by id, itemId or position

Parameters

  • comp : String/Number
    The id, itemId or position of the docked component (see getComponent for details)

Returns

  • Ext.Component   The docked component (if found)
 
Retrieve an array of all currently docked components.
Retrieve an array of all currently docked components.
 
getLoader : Ext.tree.TreeLoader
Returns the default Ext.tree.TreeLoader for this TreePanel.
Returns the default Ext.tree.TreeLoader for this TreePanel.
 
getNodeById( String id ) : Node
Gets a node in this tree by its id
Gets a node in this tree by its id

Parameters

  • id : String

Returns

  • Node   undefined
 
Returns this root node for this tree
Returns this root node for this tree
 
getSelectionModel : TreeSelectionModel
Returns the selection model used by this TreePanel.
Returns the selection model used by this TreePanel.
 
getTreeEl : Ext.core.Element
Returns the underlying Element for this tree
Returns the underlying Element for this tree
 
insertDocked( Number pos, Object/Array component. ) : Void
Inserts docked item(s) to the panel at the indicated position.
Inserts docked item(s) to the panel at the indicated position.

Parameters

  • pos : Number
    The index at which the Component will be inserted
  • component. : Object/Array
    The Component or array of components to add. The components must include a 'dock' paramater on each component to indicate where it should be docked ('top', 'right', 'bottom', 'left').

Returns

  • Void
 
removeDocked( Ext.Component item., [Boolean autoDestroy] ) : Void
Removes the docked item from the panel.
Removes the docked item from the panel.

Parameters

  • item. : Ext.Component
    The Component to remove.
  • autoDestroy : Boolean
    (optional) Destroy the component after removal.

Returns

  • Void
 
selectPath( String path, [String attr], [Function callback] ) : Void
Selects the node in this tree at the specified path. A path can be retrieved from a node with Ext.data.Node.getPath
Selects the node in this tree at the specified path. A path can be retrieved from a node with Ext.data.Node.getPath

Parameters

  • path : String
  • attr : String
    (optional) The attribute used in the path (see Ext.data.Node.getPath for more info)
  • callback : Function
    (optional) The callback to call when the selection is complete. The callback will be called with (bSuccess, oSelNode) where bSuccess is if the selection was successful and oSelNode is the selected node.

Returns

  • Void
 
setIconClass( cls undefined ) : Void
Set the iconCls for the panel's header. See Ext.panel.Header.iconCls.
Set the iconCls for the panel's header. See Ext.panel.Header.iconCls.

Parameters

  • undefined : cls

Returns

  • Void
 
setRootNode( Node node ) : Node
Sets the root node for this tree. If the TreePanel has already rendered a root node, the previous root node (and all ...
Sets the root node for this tree. If the TreePanel has already rendered a root node, the previous root node (and all of its descendants) are destroyed before the new root node is rendered.

Parameters

  • node : Node

Returns

  • Node   undefined
 
setTitle( String title ) : Void
Set a title for the panel's header. See Ext.panel.Header.title.
Set a title for the panel's header. See Ext.panel.Header.title.

Parameters

  • title : String

Returns

  • Void
 
toggleCollapse : Ext.panel.Panel
Shortcut for performing an expand or collapse based on the current state of the panel.
Shortcut for performing an expand or collapse based on the current state of the panel.

Events

 
append( Tree tree, Node parent, Node node, Number index )
Fires when a new child node is appended to a node in this tree.
Fires when a new child node is appended to a node in this tree.

Parameters

  • tree : Tree
    The owner tree
  • parent : Node
    The parent node
  • node : Node
    The newly appended node
  • index : Number
    The index of the newly appended node

Returns

  • Void
 
beforeappend( Tree tree, Node parent, Node node )
Fires before a new child is appended to a node in this tree, return false to cancel the append.
Fires before a new child is appended to a node in this tree, return false to cancel the append.

Parameters

  • tree : Tree
    The owner tree
  • parent : Node
    The parent node
  • node : Node
    The child node to be appended

Returns

  • Void
 
Fires right before the child nodes for a node are rendered
Fires right before the child nodes for a node are rendered

Parameters

  • node : Node
    The node

Returns

  • Void
 
beforeclick( Node node, Ext.EventObject e )
Fires before click processing on a node. Return false to cancel the default action.
Fires before click processing on a node. Return false to cancel the default action.

Parameters

  • node : Node
    The node
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
beforecollapsenode( Node node, Boolean deep, Boolean anim )
Fires before a node is collapsed, return false to cancel.
Fires before a node is collapsed, return false to cancel.

Parameters

  • node : Node
    The node
  • deep : Boolean
  • anim : Boolean

Returns

  • Void
 
beforedblclick( Node node, Ext.EventObject e )
Fires before double click processing on a node. Return false to cancel the default action.
Fires before double click processing on a node. Return false to cancel the default action.

Parameters

  • node : Node
    The node
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
beforeexpandnode( Node node, Boolean deep, Boolean anim )
Fires before a node is expanded, return false to cancel.
Fires before a node is expanded, return false to cancel.

Parameters

  • node : Node
    The node
  • deep : Boolean
  • anim : Boolean

Returns

  • Void
 
beforeinsert( Tree tree, Node parent, Node node, Node refNode )
Fires before a new child is inserted in a node in this tree, return false to cancel the insert.
Fires before a new child is inserted in a node in this tree, return false to cancel the insert.

Parameters

  • tree : Tree
    The owner tree
  • parent : Node
    The parent node
  • node : Node
    The child node to be inserted
  • refNode : Node
    The child node the node is being inserted before

Returns

  • Void
 
beforeload( Node node )
Fires before a node is loaded, return false to cancel
Fires before a node is loaded, return false to cancel

Parameters

  • node : Node
    The node being loaded

Returns

  • Void
 
beforemovenode( Tree tree, Node node, Node oldParent, Node newParent, Number index )
Fires before a node is moved to a new location in the tree. Return false to cancel the move.
Fires before a node is moved to a new location in the tree. Return false to cancel the move.

Parameters

  • tree : Tree
    The owner tree
  • node : Node
    The node being moved
  • oldParent : Node
    The parent of the node
  • newParent : Node
    The new parent the node is moving to
  • index : Number
    The index it is being moved to

Returns

  • Void
 
beforenodedrop( Object dropEvent )
Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The drop...
Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The dropEvent passed to handlers has the following properties:
  • tree - The TreePanel
  • target - The node being targeted for the drop
  • data - The drag data from the drag source
  • point - The point of the drop - append, above or below
  • source - The drag source
  • rawEvent - Raw mouse event
  • dropNode - Drop node(s) provided by the source OR you can supply node(s) 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.

Parameters

  • dropEvent : Object

Returns

  • Void
 
beforeremove( Tree tree, Node parent, Node node )
Fires before a child is removed from a node in this tree, return false to cancel the remove.
Fires before a child is removed from a node in this tree, return false to cancel the remove.

Parameters

  • tree : Tree
    The owner tree
  • parent : Node
    The parent node
  • node : Node
    The child node to be removed

Returns

  • Void
 
bodyresize( Ext.Panel p, Number width, Number height )
Fires after the Panel has been resized.
Fires after the Panel has been resized.

Parameters

  • p : Ext.Panel
    the Panel which has been resized.
  • width : Number
    The Panel body's new width.
  • height : Number
    The Panel body's new height.

Returns

  • Void
 
checkchange( Node this, Boolean checked )
Fires when a node with a checkbox's checked property changes
Fires when a node with a checkbox's checked property changes

Parameters

  • this : Node
    This node
  • checked : Boolean

Returns

  • Void
 
click( Node node, Ext.EventObject e )
Fires when a node is clicked
Fires when a node is clicked

Parameters

  • node : Node
    The node
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
collapsenode( Node node )
Fires when a node is collapsed
Fires when a node is collapsed

Parameters

  • node : Node
    The node

Returns

  • Void
 
containerclick( Tree this, Ext.EventObject e )
Fires when the tree container is clicked
Fires when the tree container is clicked

Parameters

  • this : Tree
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
containercontextmenu( Tree this, Ext.EventObject e )
Fires when the tree container is right clicked
Fires when the tree container is right clicked

Parameters

  • this : Tree
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
containerdblclick( Tree this, Ext.EventObject e )
Fires when the tree container is double clicked
Fires when the tree container is double clicked

Parameters

  • this : Tree
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
contextmenu( Node node, Ext.EventObject e )
Fires when a node is right clicked. To display a context menu in response to this event, first create a Menu object (...
Fires when a node is right clicked. To display a context menu in response to this event, first create a Menu object (see Ext.menu.Menu for details), then add a handler for this event:
new Ext.tree.TreePanel({
    title: 'My TreePanel',
    root: new Ext.tree.AsyncTreeNode({
        text: 'The Root',
        children: [
            { text: 'Child node 1', leaf: true },
            { text: 'Child node 2', leaf: true }
        ]
    }),
    contextMenu: new Ext.menu.Menu({
        items: [{
            id: 'delete-node',
            text: 'Delete Node'
        }],
        listeners: {
            itemclick: function(item) {
                switch (item.id) {
                    case 'delete-node':
                        var n = item.parentMenu.contextNode;
                        if (n.parentNode) {
                            n.remove();
                        }
                        break;
                }
            }
        }
    }),
    listeners: {
        contextmenu: function(node, e) {
//          Register the context node with the menu so that a Menu Item's handler function can access
//          it via its parentMenu property.
            node.select();
            var c = node.getOwnerTree().contextMenu;
            c.contextNode = node;
            c.showAt(e.getXY());
        }
    }
});

Parameters

  • node : Node
    The node
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
dblclick( Node node, Ext.EventObject e )
Fires when a node is double clicked
Fires when a node is double clicked

Parameters

  • node : Node
    The node
  • e : Ext.EventObject
    The event object

Returns

  • Void
 
disabledchange( Node node, Boolean disabled )
Fires when the disabled status of a node changes
Fires when the disabled status of a node changes

Parameters

  • node : Node
    The node
  • disabled : Boolean

Returns

  • Void
 
dragdrop( Ext.tree.TreePanel this, Ext.tree.TreeNode node, DD dd, event e )
Fires when a dragged node is dropped on a valid DD target
Fires when a dragged node is dropped on a valid DD target

Parameters

  • this : Ext.tree.TreePanel
  • node : Ext.tree.TreeNode
  • dd : DD
    The dd it was dropped on
  • e : event
    The raw browser event

Returns

  • Void
 
enddrag( Ext.tree.TreePanel this, Ext.tree.TreeNode node, event e )
Fires when a drag operation is complete
Fires when a drag operation is complete

Parameters

  • this : Ext.tree.TreePanel
  • node : Ext.tree.TreeNode
  • e : event
    The raw browser event

Returns

  • Void
 
expandnode( Node node )
Fires when a node is expanded
Fires when a node is expanded

Parameters

  • node : Node
    The node

Returns

  • Void
 
insert( Tree tree, Node parent, Node node, Node refNode )
Fires when a new child node is inserted in a node in this tree.
Fires when a new child node is inserted in a node in this tree.

Parameters

  • tree : Tree
    The owner tree
  • parent : Node
    The parent node
  • node : Node
    The child node inserted
  • refNode : Node
    The child node the node was inserted before

Returns

  • Void
 
load( Node node )
Fires when a node is loaded
Fires when a node is loaded

Parameters

  • node : Node
    The node that was loaded

Returns

  • Void
 
movenode( Tree tree, Node node, Node oldParent, Node newParent, Number index )
Fires when a node is moved to a new location in the tree
Fires when a node is moved to a new location in the tree

Parameters

  • tree : Tree
    The owner tree
  • node : Node
    The node moved
  • oldParent : Node
    The old parent of this node
  • newParent : Node
    The new parent of this node
  • index : Number
    The index it was moved to

Returns

  • Void
 
nodedragover( Object dragOverEvent )
Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent ...
Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent passed to handlers has the following properties:
  • tree - The TreePanel
  • target - The node being targeted for the drop
  • data - The drag data from the drag source
  • point - The point of the drop - append, above or below
  • source - The drag source
  • rawEvent - Raw mouse event
  • dropNode - Drop node(s) provided by the source.
  • cancel - Set this to true to signal drop not allowed.

Parameters

  • dragOverEvent : Object

Returns

  • Void
 
nodedrop( Object dropEvent )
Fires after a DD object is dropped on a node in this tree. The dropEvent passed to handlers has the following propert...
Fires after a DD object is dropped on a node in this tree. The dropEvent passed to handlers has the following properties:
  • tree - The TreePanel
  • target - The node being targeted for the drop
  • data - The drag data from the drag source
  • point - The point of the drop - append, above or below
  • source - The drag source
  • rawEvent - Raw mouse event
  • dropNode - Dropped node(s).

Parameters

  • dropEvent : Object

Returns

  • Void
 
remove( Tree tree, Node parent, Node node )
Fires when a child node is removed from a node in this tree.
Fires when a child node is removed from a node in this tree.

Parameters

  • tree : Tree
    The owner tree
  • parent : Node
    The parent node
  • node : Node
    The child node removed

Returns

  • Void
 
startdrag( Ext.tree.TreePanel this, Ext.tree.TreeNode node, event e )
Fires when a node starts being dragged
Fires when a node starts being dragged

Parameters

  • this : Ext.tree.TreePanel
  • node : Ext.tree.TreeNode
  • e : event
    The raw browser event

Returns

  • Void
 
textchange( Node node, String text, String oldText )
Fires when the text for a node is changed
Fires when the text for a node is changed

Parameters

  • node : Node
    The node
  • text : String
    The new text
  • oldText : String
    The old text

Returns

  • Void