For up to date documentation and features, visit http://docs.sencha.com/ext-js/4-0

Sencha Documentation

This class is meant to be used as a set of methods that are applied to the prototype of a Record to decorate it with a Node API. This means that models used in conjunction with a tree will have all of the tree related methods available on the model. In general this class will not be used directly by the developer.

Defined By

Methods

 
appendChild( Node/Array node, Object suppressEvents, Object suppressNodeUpdate) : Node
Insert node(s) as the last child node of this node. If the node was previously a child node of another parent node,...

Insert node(s) as the last child node of this node.

If the node was previously a child node of another parent node, it will be removed from that node first.

Parameters

  • node : Node/Array

    The node or Array of nodes to append

  • suppressEvents : Object
  • suppressNodeUpdate : Object

Returns

  • Node   

    The appended node if single append, or null if an array was passed

 
bubble( Function fn, [Object scope], [Array args]) : void
Bubbles up the tree from this node, calling the specified function with each node. The arguments to the function will...

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.

Parameters

  • fn : Function

    The function to call

  • scope : Object

    (optional) The scope (this reference) in which the function is executed. Defaults to the current Node.

  • args : Array

    (optional) The args to call the function with (default to passing the current Node)

Returns

  • void   
 
cascadeBy( Function fn, [Object scope], [Array args]) : void
Cascades down the tree from this node, calling the specified function with each node. The arguments to the function w...

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.

Parameters

  • fn : Function

    The function to call

  • scope : Object

    (optional) The scope (this reference) in which the function is executed. Defaults to the current Node.

  • args : Array

    (optional) The args to call the function with (default to passing the current Node)

Returns

  • void   
 
collapse( Function recursive, Function callback, Object scope) : void

Collapse this node.

Collapse this node.

Parameters

  • recursive : Function

    (Optional) True to recursively collapse all the children

  • callback : Function

    (Optional) The function to execute once the collapse completes

  • scope : Object

    (Optional) The scope to run the callback in

Returns

  • void   
 
collapseChildren( Function recursive, Function callback, Object scope) : void

Collapse all the children of this node.

Collapse all the children of this node.

Parameters

  • recursive : Function

    (Optional) True to recursively collapse all the children

  • callback : Function

    (Optional) The function to execute once all the children are collapsed

  • scope : Object

    (Optional) The scope to run the callback in

Returns

  • void   
 

Returns true if this node is an ancestor (at any point) of the passed node.

Returns true if this node is an ancestor (at any point) of the passed node.

Parameters

  • node : Node

Returns

  • Boolean   
 
copy( [String id], [Boolean deep]) : Node

Creates a copy (clone) of this Node.

Creates a copy (clone) of this Node.

Parameters

  • id : String

    (optional) A new id, defaults to this Node's id. See id.

  • deep : Boolean

    (optional)

    If passed as true, all child Nodes are recursively copied into the new Node.

    If omitted or false, the copy will have no child Nodes.

Returns

  • Node   

    A copy of this Node.

 

Ensures that the passed object is an instance of a Record with the NodeInterface applied

Ensures that the passed object is an instance of a Record with the NodeInterface applied

Parameters

  • node : Object

Returns

  • Boolean   
 
decorate( Ext.data.Record record) : void
This method allows you to decorate a Record's prototype to implement the NodeInterface. This adds a set of methods, n...

This method allows you to decorate a Record's prototype to implement the NodeInterface. This adds a set of methods, new events, new properties and new fields on every Record with the same Model as the passed Record.

Parameters

  • record : Ext.data.Record

    The Record you want to decorate the prototype of.

Returns

  • void   
 

Destroys the node.

Destroys the node.

Parameters

  • silent : Object

Returns

  • void   
 
eachChild( Function fn, [Object scope], [Array args]) : void
Interates the child nodes of this node, calling the specified function with each node. The arguments to the function ...

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.

Parameters

  • fn : Function

    The function to call

  • scope : Object

    (optional) The scope (this reference) in which the function is executed. Defaults to the current Node in the iteration.

  • args : Array

    (optional) The args to call the function with (default to passing the current Node)

Returns

  • void   
 
expand( Function recursive, Function callback, Object scope) : void

Expand this node.

Expand this node.

Parameters

  • recursive : Function

    (Optional) True to recursively expand all the children

  • callback : Function

    (Optional) The function to execute once the expand completes

  • scope : Object

    (Optional) The scope to run the callback in

Returns

  • void   
 
expandChildren( Function recursive, Function callback, Object scope) : void

Expand all the children of this node.

Expand all the children of this node.

Parameters

  • recursive : Function

    (Optional) True to recursively expand all the children

  • callback : Function

    (Optional) The function to execute once all the children are expanded

  • scope : Object

    (Optional) The scope to run the callback in

Returns

  • void   
 
findChild( String attribute, Mixed value, Boolean deep) : Node

Finds the first child that has the attribute with the specified value.

Finds the first child that has the attribute with the specified value.

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

 
findChildBy( Function fn, [Object scope], Boolean deep) : Node

Finds the first child by a custom function. The child matches if the function passed returns true.

Finds the first child by a custom function. The child matches if the function passed returns true.

Parameters

  • fn : Function

    A function which must return true if the passed Node is the required Node.

  • scope : Object

    (optional) The scope (this reference) 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

 

Returns the child node at the specified index.

Returns the child node at the specified index.

Parameters

  • index : Number

Returns

  • Node   
 

Returns depth of this node (the root node has a depth of 0)

Returns depth of this node (the root node has a depth of 0)

Returns

  • Number   
 

Returns true if this node has one or more child nodes, else false.

Returns true if this node has one or more child nodes, else false.

Returns

  • Boolean   
 

Returns the index of a child node

Returns the index of a child node

Parameters

  • node : Node

Returns

  • Number   

    The index of the node or -1 if it was not found

 
insertBefore( Node node, Node refNode, Object suppressEvents) : Node

Inserts the first node before the second node in this nodes childNodes collection.

Inserts the first node before the second node in this nodes childNodes collection.

Parameters

  • node : Node

    The node to insert

  • refNode : Node

    The node to insert before (if null the node is appended)

  • suppressEvents : Object

Returns

  • Node   

    The inserted node

 
insertChild( Number index, Ext.data.Model node) : Ext.data.Record

Insert a node into this node

Insert a node into this node

Parameters

  • index : Number

    The zero-based index to insert the node at

  • node : Ext.data.Model

    The node to insert

Returns

  • Ext.data.Record   

    The record you just inserted

 

Returns true if the passed node is an ancestor (at any point) of this node.

Returns true if the passed node is an ancestor (at any point) of this node.

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...

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.

Returns

  • Boolean   
 

Returns true if this node is expaned

Returns true if this node is expaned

Returns

  • Boolean   
 

Returns true if this node is the first child of its parent

Returns true if this node is the first child of its parent

Returns

  • Boolean   
 

Returns true if this node is the last child of its parent

Returns true if this node is the last child of its parent

Returns

  • Boolean   
 

Returns true if this node is a leaf

Returns true if this node is a leaf

Returns

  • Boolean   
 

Returns true if this node is loaded

Returns true if this node is loaded

Returns

  • Boolean   
 

Returns true if this node is loading

Returns true if this node is loading

Returns

  • Boolean   
 

Returns true if this node is the root node

Returns true if this node is the root node

Returns

  • Boolean   
 

Returns true if this node is visible

Returns true if this node is visible

Returns

  • Boolean   
 
remove( Boolean destroy, Object suppressEvents) : Node

Removes this node from its parent

Removes this node from its parent

Parameters

  • destroy : Boolean

    true to destroy the node upon removal. Defaults to false.

  • suppressEvents : Object

Returns

  • Node   

    this

 
removeAll( Boolean destroy, Object suppressEvents) : Node

Removes all child nodes from this node.

Removes all child nodes from this node.

Parameters

  • destroy : Boolean

    true to destroy the node upon removal. Defaults to false.

  • suppressEvents : Object

Returns

  • Node   

    this

 
removeChild( Node node, Boolean destroy, Object suppressEvents, Object suppressNodeUpdate) : Node

Removes a child node from this node.

Removes a child node from this node.

Parameters

  • node : Node

    The node to remove

  • destroy : Boolean

    true to destroy the node upon removal. Defaults to false.

  • suppressEvents : Object
  • suppressNodeUpdate : Object

Returns

  • Node   

    The removed node

 
replaceChild( Node newChild, Node oldChild, Object suppressEvents) : Node

Replaces one child node in this node with another.

Replaces one child node in this node with another.

Parameters

  • newChild : Node

    The replacement node

  • oldChild : Node

    The node to replace

  • suppressEvents : Object

Returns

  • Node   

    The replaced node

 
sort( Function fn, Boolean recursive, Boolean suppressEvent) : void

Sorts this nodes children using the supplied sort function.

Sorts this nodes children using the supplied sort function.

Parameters

  • fn : Function

    A function which, when passed two Nodes, returns -1, 0 or 1 depending upon required sort order.

  • recursive : Boolean

    Whether or not to apply this sort recursively

  • suppressEvent : Boolean

    Set to true to not fire a sort event.

Returns

  • void   
 
Updates general data of this node like isFirst, isLast, depth. This method is internally called after a node is moved...

Updates general data of this node like isFirst, isLast, depth. This method is internally called after a node is moved. This shouldn't have to be called by the developer unless they are creating custom Tree plugins.

Parameters

  • silent : Object

Returns

  • Boolean   
Defined By

Events

 
append( Node this, Node node, Number index)

Fires when a new child node is appended

Fires when a new child node is appended

Parameters

  • 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.

Fires before a new child is appended, return false to cancel the append.

Parameters

  • this : Node

    This node

  • node : Node

    The child node to be appended

 

Fires before this node is collapsed.

Fires before this node is collapsed.

Parameters

  • this : Node

    The collapsing node

 

Fires before this node is expanded.

Fires before this node is expanded.

Parameters

  • this : Node

    The expanding node

 
beforeinsert( Node this, Node node, Node refNode)

Fires before a new child is inserted, return false to cancel the insert.

Fires before a new child is inserted, return false to cancel the insert.

Parameters

  • this : Node

    This node

  • node : Node

    The child node to be inserted

  • refNode : Node

    The child node the node is being inserted before

 
beforemove( Node this, Node oldParent, Node newParent, Number index)

Fires before this node is moved to a new location in the tree. Return false to cancel the move.

Fires before this node is moved to a new location in the tree. Return false to cancel the move.

Parameters

  • 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.

Fires before a child is removed, return false to cancel the remove.

Parameters

  • this : Node

    This node

  • node : Node

    The child node to be removed

 

Fires when this node is collapsed.

Fires when this node is collapsed.

Parameters

  • this : Node

    The collapsing node

 

Fires when this node is expanded.

Fires when this node is expanded.

Parameters

  • this : Node

    The expanding node

 
insert( Node this, Node node, Node refNode)

Fires when a new child node is inserted.

Fires when a new child node is inserted.

Parameters

  • this : Node

    This node

  • node : Node

    The child node inserted

  • refNode : Node

    The child node the node was inserted before

 
move( Node this, Node oldParent, Node newParent, Number index)

Fires when this node is moved to a new location in the tree

Fires when this node is moved to a new location in the tree

Parameters

  • 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

Fires when a child node is removed

Parameters

  • this : Node

    This node

  • node : Node

    The removed node