Ext.tree.TreeNode
Hierarchy
Ext.util.ObservableExt.data.NodeExt.tree.TreeNodeSubclasses
Files
Available since: 1.1.0
Config options
False to not allow this node to have child nodes (defaults to true)
False to not allow this node to have child nodes (defaults to true)
Available since: 1.1.0
False if this node cannot have child nodes dropped on it (defaults to true)
False if this node cannot have child nodes dropped on it (defaults to true)
Available since: 1.1.0
True to render a checked checkbox for this node, false to render an unchecked checkbox (defaults to undefined with no checkbox rendered)
Available since: 1.1.0
true to start the node disabled
true to start the node disabled
Available since: 1.1.0
True to make this node draggable (defaults to false)
True to make this node draggable (defaults to false)
Available since: 1.1.0
False to not allow this node to be edited by an Ext.tree.TreeEditor (defaults to true)
False to not allow this node to be edited by an Ext.tree.TreeEditor (defaults to true)
Available since: 2.3.0
If set to true, the node will always show a plus/minus icon, even when empty
If set to true, the node will always show a plus/minus icon, even when empty
Available since: 2.3.0
true to start the node expanded
true to start the node expanded
Available since: 1.1.0
URL of the link used for the node (defaults to #)
URL of the link used for the node (defaults to #)
Available since: 1.1.0
The path to an icon for the node. The preferred way to do this is to use the cls or iconCls attributes and add the icon via a CSS background image.
Available since: 1.1.0
A css class to be added to the nodes icon element for applying css background images
A css class to be added to the nodes icon element for applying css background images
Available since: 1.1.0
The id for this node. If one is not specified, one is generated.
Available since: 1.1.0
False to not allow this node to act as a drop target (defaults to true)
False to not allow this node to act as a drop target (defaults to true)
Available since: 1.1.0
true if this node is a leaf and does not have children
true if this node is a leaf and does not have children
Available since: 1.1.0
(optional)
A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once.
DOM events from ExtJs Components
While some ExtJs Component classes export selected DOM events (e.g. "click", "mouseover" etc), this
is usually only done when extra value can be added. For example the DataView's
click event passing the node clicked on. To access DOM
events directly from a Component's HTMLElement, listeners must be added to the Element after the Component
has been rendered. A plugin can simplify this step:
// Plugin is configured with a listeners config object.
// The Component is appended to the argument list of all handler functions.
Ext.DomObserver = Ext.extend(Object, {
constructor: function(config) {
this.listeners = config.listeners ? config.listeners : config;
},
// Component passes itself into plugin's init method
init: function(c) {
var p, l = this.listeners;
for (p in l) {
if (Ext.isFunction(l[p])) {
l[p] = this.createHandler(l[p], c);
} else {
l[p].fn = this.createHandler(l[p].fn, c);
}
}
// Add the listeners to the Element immediately following the render call
c.render = c.render.createSequence(function() {
var e = c.getEl();
if (e) {
e.on(l);
}
});
},
createHandler: function(fn, c) {
return function(e) {
fn.call(this, e, c);
};
}
});
var combo = new Ext.form.ComboBox({
// Collapse combo when its element is clicked on
plugins: [ new Ext.DomObserver({
click: function(evt, comp) {
comp.collapse();
}
})],
store: myStore,
typeAhead: true,
mode: 'local',
triggerAction: 'all'
});
Available since: 1.1.0
An Ext QuickTip config for the node (used instead of qtip)
An Ext QuickTip config for the node (used instead of qtip)
Available since: 1.1.0
True for single click expand on this node
True for single click expand on this node
Available since: 1.1.0
A UI class to use for this node (defaults to Ext.tree.TreeNodeUI)
A UI class to use for this node (defaults to Ext.tree.TreeNodeUI)
Available since: 1.1.0
Properties
The attributes supplied for the node. You can use this property to access any custom attributes you supplied.
Available since: 1.1.0
All child nodes of this node.
Defaults to: []
Available since: 1.1.0
True if this node is disabled.
True if this node is disabled.
Available since: 1.1.0
The first direct child node of this node, or null if this node has no child nodes.
The first direct child node of this node, or null if this node has no child nodes.
Available since: 1.1.0
The last direct child node of this node, or null if this node has no child nodes.
The last direct child node of this node, or null if this node has no child nodes.
Available since: 1.1.0
The node immediately following this node in the tree, or null if there is no sibling node.
The node immediately following this node in the tree, or null if there is no sibling node.
Available since: 1.1.0
The parent node for this node.
The parent node for this node.
Available since: 1.1.0
The node immediately preceding this node in the tree, or null if there is no sibling node.
The node immediately preceding this node in the tree, or null if there is no sibling node.
Available since: 1.1.0
Read-only. The text for this node. To change it use setText.
Available since: 1.1.0
Methods
Available since: 1.1.0
Parameters
- attributes : Object/String
The attributes/config for the node or just a string with the text for the node
Returns
Overrides: Ext.data.Node.constructor
Adds the specified events to the list of events which this Observable may fire.
Available since: 1.1.0
Parameters
- o : Object|String
Either an object with event names as properties with a value of
trueor the first event name string if multiple event names are being passed as separate parameters. - Optional : string
. Event name if multiple event names are being passed as separate parameters. Usage:
this.addEvents('storeloaded', 'storecleared');
Appends an event handler to this object.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to listen for.
- handler : Function
The method the event invokes.
- scope : Object (optional)
The scope (
thisreference) in which the handler function is executed. If omitted, defaults to the object which fired the event. - options : Object (optional)
An object containing handler configuration. properties. This may contain any of the following properties:
- scope : ObjectThe scope (
thisreference) in which the handler function is executed. If omitted, defaults to the object which fired the event. - delay : NumberThe number of milliseconds to delay the invocation of the handler after the event fires.
- single : BooleanTrue to add a handler to handle just the next firing of the event, and then remove itself.
- buffer : NumberCauses the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.
- target : ObservableOnly call the handler if the event was fired on the target Observable, not if the event was bubbled up from a child Observable.
Combining Options
Using the options argument, it is possible to combine different types of listeners:
A delayed, one-time listener.myDataView.on('click', this.onClick, this, { single: true, delay: 100 });Attaching multiple handlers in 1 call
The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers.myGridPanel.on({ 'click' : { fn: this.onClick, scope: this, delay: 100 }, 'mouseover' : { fn: this.onMouseOver, scope: this }, 'mouseout' : { fn: this.onMouseOut, scope: this } });Or a shorthand syntax:
myGridPanel.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut, scope: this }); - scope : Object
these methods are overridden to provide lazy rendering support private override
Insert node(s) as the last child node of this node.
Available since: 1.1.0
Parameters
- node : Node/Array
The node or Array of nodes to append
Returns
- Node
The appended node if single append, or null if an array was passed
Overrides: Ext.data.Node.appendChild
Bubbles up the tree from this node, calling the specified function with each node. The arguments to the function will be the args provided or the current node. If the function returns false at any point, the bubble is stopped.
Available since: 1.1.0
Parameters
Cascades down the tree from this node, calling the specified function with each node. The arguments to the function will be the args provided or the current node. If the function returns false at any point, the cascade is stopped on that branch.
Available since: 1.1.0
Parameters
Collapse this node.
Available since: 1.1.0
Parameters
- deep : Boolean (optional)
True to collapse all children as well
- anim : Boolean (optional)
false to cancel the default animation
- callback : Function (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.
- scope : Object (optional)
The scope (
thisreference) in which the callback is executed. Defaults to this TreeNode.
Collapse all child nodes
Available since: 1.1.0
Parameters
- deep : Boolean (optional)
true if the child nodes should also collapse their child nodes
Returns true if this node is an ancestor (at any point) of the passed node.
Available since: 1.1.0
Parameters
- node : Node
Returns
- Boolean
private
Available since: Ext JS 3.4.0
Parameters
- delay : Object
inherit docs
Destroys the node.
Available since: Ext JS 3.4.0
Parameters
- silent : Object
Overrides: Ext.data.Node.destroy
Interates the child nodes of this node, calling the specified function with each node. The arguments to the function will be the args provided or the current node. If the function returns false at any point, the iteration stops.
Available since: 1.1.0
Parameters
Enables events fired by this Observable to bubble up an owner hierarchy by calling
this.getBubbleTarget() if present. There is no implementation in the Observable base class.
This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly.
Example:
Ext.override(Ext.form.Field, {
// Add functionality to Field's initComponent to enable the change event to bubble
initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {
this.enableBubble('change');
}),
// We know that we want Field's events to bubble directly to the FormPanel.
getBubbleTarget : function() {
if (!this.formPanel) {
this.formPanel = this.findParentByType('form');
}
return this.formPanel;
}
});
var myForm = new Ext.formPanel({
title: 'User Details',
items: [{
...
}],
listeners: {
change: function() {
// Title goes red if form has been modified.
myForm.header.setStyle('color', 'red');
}
}
});
Available since: Ext JS 3.4.0
Parameters
Ensures all parent nodes are expanded, and if necessary, scrolls the node into view.
Available since: 1.1.0
Parameters
- callback : Function (optional)
A function to call when the node has been made visible.
- scope : Object (optional)
The scope (
thisreference) in which the callback is executed. Defaults to this TreeNode.
Expand this node.
Available since: 1.1.0
Parameters
- deep : Boolean (optional)
True to expand all children as well
- anim : Boolean (optional)
false to cancel the default animation
- callback : Function (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.
- scope : Object (optional)
The scope (
thisreference) in which the callback is executed. Defaults to this TreeNode.
Expand all child nodes
Available since: 1.1.0
Parameters
- deep : Boolean (optional)
true if the child nodes should also expand their child nodes
Finds the first child that has the attribute with the specified value.
Available since: 1.1.0
Parameters
- attribute : String
The attribute name
- value : Mixed
The value to search for
- deep : Boolean (optional)
True to search through nodes deeper than the immediate children
Returns
- Node
The found child or null if none was found
Finds the first child by a custom function. The child matches if the function passed returns true.
Available since: 1.1.0
Parameters
- fn : Function
A function which must return
trueif the passed Node is the required Node. - scope : Object (optional)
The scope (
thisreference) in which the function is executed. Defaults to the Node being tested. - deep : Boolean (optional)
True to search through nodes deeper than the immediate children
Returns
- Node
The found child or null if none was found
private
Fires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble.
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to fire.
- args : Object...
Variable number of parameters are passed to handlers.
Returns
- Boolean
returns false if any of the handlers return false otherwise it returns true.
Overrides: Ext.util.Observable.fireEvent
Returns the tree this node is in.
Available since: 1.1.0
Returns
- Tree
Returns the UI object for this node.
Available since: 1.1.0
Returns
- TreeNodeUI
The object which is providing the user interface for this tree node. Unless otherwise specified in the uiProvider, this will be an instance of Ext.tree.TreeNodeUI
Returns true if this node has one or more child nodes, else false.
Available since: 2.3.0
Returns
- Boolean
Checks to see if this object has any listeners for a specified event
Available since: 1.1.0
Parameters
- eventName : String
The name of the event to check for
Returns
- Boolean
True if the event is being listened for, else false
Returns the index of a child node
Available since: 1.1.0
Parameters
- node : Node
Returns
- Number
The index of the node or -1 if it was not found
private override
Inserts the first node before the second node in this nodes childNodes collection.
Available since: 1.1.0
Parameters
- node : Node
The node to insert
- refNode : Node
The node to insert before (if null the node is appended)
Returns
- Node
The inserted node
Overrides: Ext.data.Node.insertBefore
Returns true if the passed node is an ancestor (at any point) of this node.
Available since: 1.1.0
Parameters
- node : Node
Returns
- Boolean
Returns true if this node has one or more child nodes, or if the expandable node attribute is explicitly specified as true (see attributes), otherwise returns false.
Available since: 2.3.0
Returns
- Boolean
Returns true if this node is expanded
Available since: 1.1.0
Returns
- Boolean
Returns true if this node is the first child of its parent
Available since: 1.1.0
Returns
- Boolean
Returns true if this node is the last child of its parent
Available since: 1.1.0
Returns
- Boolean
Returns true if this node is a leaf
Available since: 1.1.0
Returns
- Boolean
Returns true if this node is selected
Available since: 1.1.0
Returns
- Boolean
Returns the child node at the specified index.
Available since: 1.1.0
Parameters
- index : Number
Returns
- Node
Appends an event handler to this object (shorthand for addListener.)
Available since: 1.1.0
Parameters
- eventName : String
The type of event to listen for
- handler : Function
The method the event invokes
- scope : Object (optional)
The scope (
thisreference) in which the handler function is executed. If omitted, defaults to the object which fired the event. - options : Object (optional)
An object containing handler configuration.
Removes all listeners for this object
Available since: 1.1.0
Relays selected events from the specified Observable as if the events were fired by this.
Available since: 2.3.0
Parameters
- o : Object
The Observable whose events this object is to relay.
- events : Array
Array of event names to relay.
Removes this node from its parent
Available since: 2.3.0
Parameters
- destroy : Boolean
true to destroy the node upon removal. Defaults to false.
Returns
- Node
this
Removes all child nodes from this node.
Available since: Ext JS 3.4.0
Parameters
- destroy : Boolean
true to destroy the node upon removal. Defaults to false.
Returns
- Node
this
private override
Removes a child node from this node.
Available since: 1.1.0
Parameters
- node : Node
The node to remove
- destroy : Boolean
true to destroy the node upon removal. Defaults to false.
Returns
- Node
The removed node
Overrides: Ext.data.Node.removeChild
Removes an event handler.
Available since: 1.1.0
Parameters
- eventName : String
The type of event the handler was associated with.
- handler : Function
The handler to remove. This must be a reference to the function passed into the addListener call.
- scope : Object (optional)
The scope originally specified for the handler.
private
Available since: Ext JS 3.4.0
Parameters
- bulkRender : Object
private
Available since: Ext JS 3.4.0
Parameters
- suppressEvent : Object
private
Available since: Ext JS 3.4.0
Parameters
- deep : Object
- refresh : Object
Replaces one child node in this node with another.
Available since: 1.1.0
Parameters
- newChild : Node
The replacement node
- oldChild : Node
The node to replace
Returns
- Node
The replaced node
Resume firing events. (see suspendEvents) If events were suspended using the queueSuspended parameter, then all events fired during event suspension will be sent to any listeners now.
Available since: 2.3.0
Available since: Ext JS 3.4.0
Parameters
- cb : Object
- scope : Object
- args : Object
private override
Available since: Ext JS 3.4.0
Parameters
- node : Object
Overrides: Ext.data.Node.setFirstChild
Changes the id of this node.
Available since: Ext JS 3.4.0
Parameters
- id : String
The new id for the node.
private override
Available since: Ext JS 3.4.0
Parameters
- node : Object
Overrides: Ext.data.Node.setLastChild
private
Available since: Ext JS 3.4.0
Parameters
- tree : Object
- destroy : Object
private
Sorts this nodes children using the supplied sort function.
Available since: 1.1.0
Parameters
- fn : Function
A function which, when passed two Nodes, returns -1, 0 or 1 depending upon required sort order.
- scope : Object (optional)
The scope (
thisreference) in which the function is executed. Defaults to the browser window.
Overrides: Ext.data.Node.sort
Suspend the firing of all events. (see resumeEvents)
Available since: 2.3.0
Parameters
- queueSuspended : Boolean
Pass as true to queue up suspended events to be fired after the resumeEvents call instead of discarding all suspended events;
Toggles expanded/collapsed state of the node
Available since: 1.1.0
Removes an event handler (shorthand for removeListener.)
Available since: 1.1.0
Parameters
- eventName : String
The type of event the handler was associated with.
- handler : Function
The handler to remove. This must be a reference to the function passed into the addListener call.
- scope : Object (optional)
The scope originally specified for the handler.
Triggers deselection of this node
Available since: 1.1.0
Parameters
- silent : Boolean (optional)
True to stop selection change events from firing.
Events
Fires when a new child node is appended
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- node : Node
The newly appended node
- index : Number
The index of the newly appended node
Fires before a new child is appended, return false to cancel the append.
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- node : Node
The child node to be appended
Fires right before the child nodes for this node are rendered
Available since: 1.1.0
Parameters
- this : Node
This node
Fires before click processing. Return false to cancel the default action.
Available since: 1.1.0
Parameters
- this : Node
This node
- e : Ext.EventObject
The event object
Fires before this node is collapsed, return false to cancel.
Available since: 1.1.0
Parameters
- this : Node
This node
- deep : Boolean
- anim : Boolean
Fires before double click processing. Return false to cancel the default action.
Available since: Ext JS 3.4.0
Parameters
- this : Node
This node
- e : Ext.EventObject
The event object
Fires before this node is expanded, return false to cancel.
Available since: 1.1.0
Parameters
- this : Node
This node
- deep : Boolean
- anim : Boolean
Fires before a new child is inserted, return false to cancel the insert.
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- node : Node
The child node to be inserted
- refNode : Node
The child node the node is being inserted before
Fires before this node is moved to a new location in the tree. Return false to cancel the move.
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- oldParent : Node
The parent of this node
- newParent : Node
The new parent this node is moving to
- index : Number
The index it is being moved to
Fires before a child is removed, return false to cancel the remove.
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- node : Node
The child node to be removed
Fires when a node with a checkbox's checked property changes
Available since: 1.1.0
Parameters
- this : Node
This node
- checked : Boolean
Fires when this node is clicked
Available since: 1.1.0
Parameters
- this : Node
This node
- e : Ext.EventObject
The event object
Fires when this node is collapsed
Available since: 1.1.0
Parameters
- this : Node
This node
Fires when this node is double clicked
Available since: 1.1.0
Parameters
- this : Node
This node
- e : Ext.EventObject
The event object
Fires when the disabled status of this node changes
Available since: 1.1.0
Parameters
- this : Node
This node
- disabled : Boolean
Fires when this node is expanded
Available since: 1.1.0
Parameters
- this : Node
This node
Fires when a new child node is inserted.
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- node : Node
The child node inserted
- refNode : Node
The child node the node was inserted before
Fires when this node is moved to a new location in the tree
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- oldParent : Node
The old parent of this node
- newParent : Node
The new parent of this node
- index : Number
The index it was moved to
Fires when a child node is removed
Available since: 1.1.0
Parameters
- tree : Tree
The owner tree
- this : Node
This node
- node : Node
The removed node