Clear Up
SharpKit Reference

NodeInterface Class

This class is used as a set of methods that are applied to the prototype of a Model 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. This class also creates extra fields on the model if they do not exist, to help maintain the tree state and UI. These fields are documented as config options.

Namespace: Ext.data

Base Types

Fields

Name Description
allowDrag Set to false to deny dragging of this node. Defaults to: true
allowDrop Set to false to deny dropping on this node. Defaults to: true
checked Set to true or false to show a checkbox alongside this node. Defaults to: null
children Array of child nodes.
cls CSS class to apply for this node.
depth The number of parents this node has. A root node has depth 0, a child of it depth 1, and so on...
expandable Set to true to allow for expanding/collapsing of this node. Defaults to: false
expanded True if the node is expanded. Defaults to: false
href An URL for a link that's created when this config is specified.
hrefTarget Target for link. Only applicable when href also specified.
icon URL for this node's icon.
iconCls CSS class to apply for this node's icon.
index The position of the node inside its parent. When parent has 4 children and the node is third amongst them, index will be 2.
leaf Set to true to indicate that this child can have no children. The expand icon/arrow will then not be rendered for this node. Defaults to: false
loaded True if the node has finished loading. Defaults to: false
loading True if the node is currently loading. Defaults to: false
parentId ID of parent node.
qtip Tooltip text to show on this node.
qtitle Tooltip title.
root True if this is the root node.
text The text for to show on node label.

Methods

Name Description
appendChild(object) Inserts 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.
bubble(Delegate, object, object) 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.
cascadeBy(Delegate, object, object) 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.
collapse(object, object, object) Collapse this node.
collapseChildren(object, object, object) Collapse all the children of this node.
contains(NodeInterface) Returns true if this node is an ancestor (at any point) of the passed node.
copy(object, object) Creates a copy (clone) of this Node.
createNode(object) Ensures that the passed object is an instance of a Record with the NodeInterface applied
decorate(object) This method allows you to decorate a Model's class to implement the NodeInterface. This adds a set of methods, new events, new properties and new fields on every Record.
destroy(object) Destroys the node.
eachChild(Delegate, object, object) 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.
expand(object, object, object) Expand this node.
expandChildren(object, object, object) Expand all the children of this node.
findChild(JsString, object, object) Finds the first child that has the attribute with the specified value.
findChildBy(Delegate, object, object) Finds the first child by a custom function. The child matches if the function passed returns true.
getChildAt(JsNumber) Returns the child node at the specified index.
getDepth() Returns depth of this node (the root node has a depth of 0)
getPath(object, object) Gets the hierarchical path from the root of the current node.
hasChildNodes() Returns true if this node has one or more child nodes, else false.
indexOf(NodeInterface) Returns the index of a child node
indexOfId(JsString) Returns the index of a child node that matches the id
insertBefore(NodeInterface, NodeInterface) Inserts the first node before the second node in this nodes childNodes collection.
insertChild(JsNumber, NodeInterface) Inserts a node into this node.
isAncestor(NodeInterface) Returns true if the passed node is an ancestor (at any point) of this node.
isExpandable() Returns true if this node has one or more child nodes, or if the expandable node attribute is explicitly specified as true, otherwise returns false.
isExpanded() Returns true if this node is expaned
isFirst() Returns true if this node is the first child of its parent
isLast() Returns true if this node is the last child of its parent
isLeaf() Returns true if this node is a leaf
isLoaded() Returns true if this node is loaded
isLoading() Returns true if this node is loading
isRoot() Returns true if this node is the root node
isVisible() Returns true if this node is visible
remove(object) Removes this node from its parent
removeAll(object) Removes all child nodes from this node.
removeChild(NodeInterface, object) Removes a child node from this node.
replaceChild(NodeInterface, NodeInterface) Replaces one child node in this node with another.
sort(Delegate, object, object) Sorts this nodes children using the supplied sort function.
updateInfo(object) 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.

Properties

Name Description
childNodes An array of this nodes children. Array will be empty if this node has no chidren.
firstChild A reference to this node's first child node. null if this node has no children.
isNode true in this class to identify an object as an instantiated Node, or subclass thereof. Defaults to: true
lastChild A reference to this node's last child node. null if this node has no children.
nextSibling A reference to this node's next sibling node. null if this node does not have a next sibling.
parentNode A reference to this node's parent node. null if this node is the root node.
previousSibling A reference to this node's previous sibling node. null if this node does not have a previous sibling.
© Copyright 2005-2011 SharpKit. All rights reserved.