Class: TreeNode

TreeNode(source) → {TreeNode}

Represents a singe node object within the tree.

Constructor

new TreeNode(source) → {TreeNode}

Parameters:
Name Type Description
source TreeNode TreeNode to copy.
Source:
Returns:
Tree node object.
Type
TreeNode

Methods

addChild(child) → {TreeNode}

Add a child to this node.
Parameters:
Name Type Description
child object Node object.
Source:
Returns:
Node object.
Type
TreeNode

addChildren(children) → {TreeNodes}

Add multiple children to this node.
Parameters:
Name Type Description
children object Array of nodes.
Source:
Returns:
Array of node objects.
Type
TreeNodes

assign(source) → {TreeNode}

Assign source object(s) to this node.
Parameters:
Name Type Description
source object Source object(s)
Source:
Returns:
Node object.
Type
TreeNode

available() → {boolean}

Check if node available.
Source:
Returns:
True if available.
Type
boolean

blur() → {TreeNode}

Blur focus from this node.
Source:
Returns:
Node object.
Type
TreeNode

check(shallow) → {TreeNode}

Mark node as checked.
Parameters:
Name Type Description
shallow boolean Skip auto-checking children.
Source:
Returns:
Node object.
Type
TreeNode

checked() → {boolean}

Get whether this node is checked.
Source:
Returns:
True if node checked.
Type
boolean

clean() → {TreeNode}

Hide parents without any visible children.
Source:
Returns:
Node object.
Type
TreeNode

clone(excludeKeys) → {TreeNode}

Clone this node.
Parameters:
Name Type Description
excludeKeys array Keys to exclude from the clone.
Source:
Returns:
New node object.
Type
TreeNode

collapse() → {TreeNode}

Collapse this node.
Source:
Returns:
Node object.
Type
TreeNode

collapsed() → {boolean}

Get whether this node is collapsed.
Source:
Returns:
True if node collapsed.
Type
boolean

context() → {TreeNodes}

Get the containing context. If no parent present, the root context is returned.
Source:
Returns:
Node array object.
Type
TreeNodes

copy(dest, hierarchy, includeState) → {object}

Copy node to another tree instance.
Parameters:
Name Type Description
dest object Destination Inspire Tree.
hierarchy boolean Include necessary ancestors to match hierarchy.
includeState boolean Include itree.state object.
Source:
Returns:
Property "to" for defining destination.
Type
object

copyHierarchy(excludeNode, includeState) → {TreeNode}

Copy all parents of a node.
Parameters:
Name Type Description
excludeNode boolean Exclude given node from hierarchy.
includeState boolean Include itree.state object.
Source:
Returns:
Root node object with hierarchy.
Type
TreeNode

deselect(shallow) → {TreeNode}

Deselect this node. If selection.require is true and this is the last selected node, the node will remain in a selected state.
Parameters:
Name Type Description
shallow boolean Skip auto-deselecting children.
Source:
Returns:
Node object.
Type
TreeNode

editable() → {boolean}

Get whether node editable. Required editing.edit to be enable via config.
Source:
Returns:
True if node editable.
Type
boolean

editing() → {boolean}

Get whether node is currently in edit mode.
Source:
Returns:
True if node in edit mode.
Type
boolean

expand() → {Promise.<TreeNode>}

Expand this node.
Source:
Returns:
Promise resolved on successful load and expand of children.
Type
Promise.<TreeNode>

expanded() → {boolean}

Get whether node expanded.
Source:
Returns:
True if expanded.
Type
boolean

expandParents() → {TreeNode}

Expand parent nodes.
Source:
Returns:
Node object.
Type
TreeNode

focus() → {TreeNode}

Focus a node without changing its selection.
Source:
Returns:
Node object.
Type
TreeNode

focused() → {boolean}

Get whether this node is focused.
Source:
Returns:
True if node focused.
Type
boolean

getChildren() → {TreeNodes}

Get children for this node. If no children exist, an empty TreeNodes collection is returned for safe chaining.
Source:
Returns:
Array of node objects.
Type
TreeNodes

getParent() → {TreeNode}

Get the immediate parent, if any.
Source:
Returns:
Node object.
Type
TreeNode

getParents() → {TreeNodes}

Get parent nodes. Excludes any siblings.
Source:
Returns:
Node objects.
Type
TreeNodes

getTextualHierarchy() → {array}

Get a textual hierarchy for a given node. An array of text from this node's root ancestor to the given node.
Source:
Returns:
Array of node texts.
Type
array

hasAncestor(node) → {boolean}

Get whether the given node is an ancestor of this node.
Parameters:
Name Type Description
node TreeNode Node object.
Source:
Returns:
True if node is an ancestor or the given node
Type
boolean

hasChildren() → {boolean}

Get whether node has any children.
Source:
Returns:
True if has loaded children.
Type
boolean

hasLoadedChildren() → {boolean}

Get whether children have been loaded. Will always be true for non-dynamic nodes.
Source:
Returns:
True if we've attempted to load children.
Type
boolean

hasOrWillHaveChildren() → {boolean}

Get whether node has any children, or allows dynamic loading.
Source:
Returns:
True if node has, or will have children.
Type
boolean

hasParent() → {boolean}

Get whether node has a parent.
Source:
Returns:
True if has a parent.
Type
boolean

hasVisibleChildren() → {boolean}

Get whether node has any visible children.
Source:
Returns:
True if children are visible.
Type
boolean

hidden() → {boolean}

Get whether this node is hidden.
Source:
Returns:
True if node hidden.
Type
boolean

hide() → {TreeNode}

Hide this node.
Source:
Returns:
Node object.
Type
TreeNode

indeterminate() → {boolean}

Get whether this node is indeterminate.
Source:
Returns:
True if node indeterminate.
Type
boolean

indexPath() → {string}

Get a "path" of indices, values which map this node's location within all parent contexts.
Source:
Returns:
Index path
Type
string

isFirstRenderable() → {boolean}

Get whether this node is the first renderable in its context.
Source:
Returns:
True if node is first renderable
Type
boolean

isLastRenderable() → {boolean}

Get whether this node is the last renderable in its context.
Source:
Returns:
True if node is last renderable
Type
boolean

isOnlyRenderable() → {boolean}

Get whether this node is the only renderable in its context.
Source:
Returns:
True if node is only renderable
Type
boolean

lastDeepestVisibleChild() → {TreeNode}

Find the last + deepest visible child of the previous sibling.
Source:
Returns:
Node object.
Type
TreeNode

loadChildren() → {Promise.<TreeNodes>}

Initiate a dynamic load of children for a given node. This requires `tree.config.data` to be a function which accepts three arguments: node, resolve, reject. Use the `node` to filter results. On load success, pass the result array to `resolve`. On error, pass the Error to `reject`.
Source:
Returns:
Promise resolving children nodes.
Type
Promise.<TreeNodes>

loading() → {boolean}

Get whether this node is loading child data.
Source:
Returns:
True if node's children are loading.
Type
boolean

loadMore(event) → {Promise.<TreeNodes>}

Load additional children.
Parameters:
Name Type Description
event Event Click or scroll event if DOM interaction triggered this call.
Source:
Returns:
Resolves with request results.
Type
Promise.<TreeNodes>

markDirty() → {TreeNode}

Mark node as dirty. For some systems this assists with rendering tracking.
Source:
Returns:
Node object.
Type
TreeNode

matched() → {boolean}

Get whether this node was matched during the last search.
Source:
Returns:
True if node matched.
Type
boolean

nextVisibleAncestralSiblingNode() → {TreeNode}

Find the next visible sibling of our ancestor. Continues seeking up the tree until a valid node is found or we reach the root node.
Source:
Returns:
Node object.
Type
TreeNode

nextVisibleChildNode() → {TreeNode}

Find next visible child node.
Source:
Returns:
Node object, if any.
Type
TreeNode

nextVisibleNode() → {TreeNode}

Get the next visible node.
Source:
Returns:
Node object if any.
Type
TreeNode

nextVisibleSiblingNode() → {TreeNode}

Find the next visible sibling node.
Source:
Returns:
Node object, if any.
Type
TreeNode

pagination() → {object}

Get pagination object for this tree node.
Source:
Returns:
Pagination configuration object.
Type
object

previousVisibleNode() → {TreeNode}

Find the previous visible node.
Source:
Returns:
Node object, if any.
Type
TreeNode

previousVisibleSiblingNode() → {TreeNode}

Find the previous visible sibling node.
Source:
Returns:
Node object, if any.
Type
TreeNode

recurseDown(iteratee) → {TreeNode}

Iterate down node and any children.
Parameters:
Name Type Description
iteratee function Iteratee function.
Source:
Returns:
Node object.
Type
TreeNode

recurseUp(iteratee) → {TreeNode}

Iterate up a node and its parents.
Parameters:
Name Type Description
iteratee function Iteratee function.
Source:
Returns:
Node object.
Type
TreeNode

refreshIndeterminateState() → {TreeNode}

Update the indeterminate state of this node by scanning states of children. True if some, but not all children are checked. False if no children are checked.
Source:
Returns:
Node object.
Type
TreeNode

reload() → {Promise.<TreeNodes>}

Remove all current children and re-execute a loadChildren call.
Source:
Returns:
Promise resolved on load.
Type
Promise.<TreeNodes>

remove(includeState) → {object}

Remove a node from the tree.
Parameters:
Name Type Default Description
includeState boolean false Include itree.state object.
Source:
Returns:
Removed tree node object.
Type
object

removed() → {boolean}

Get whether this node is soft-removed.
Source:
Returns:
True if node soft-removed.
Type
boolean

renderable() → {boolean}

Get whether this node can be "rendered" when the context is. Hidden and removed nodes may still be included in the DOM, but not "rendered" in a sense they'll be visible.
Source:
Returns:
If not hidden or removed
Type
boolean

rendered() → {boolean}

Get whether this node has been rendered. Will be false if deferred rendering is enable and the node has not yet been loaded, or if a custom DOM renderer is used.
Source:
Returns:
True if node rendered.
Type
boolean

restore() → {TreeNode}

Restore state if soft-removed.
Source:
Returns:
Node object.
Type
TreeNode

select(shallow) → {TreeNode}

Select this node.
Parameters:
Name Type Description
shallow boolean Skip auto-selecting children.
Source:
Returns:
Node object.
Type
TreeNode

selectable() → {boolean}

Get whether node selectable.
Source:
Returns:
True if node selectable.
Type
boolean

selected() → {boolean}

Get whether this node is selected.
Source:
Returns:
True if node selected.
Type
boolean

set(property, value) → {TreeNode}

Set a root property on this node.
Parameters:
Name Type Description
property string | number Property name.
value * New value.
Source:
Returns:
Node object.
Type
TreeNode

show() → {TreeNode}

Show this node.
Source:
Returns:
Node object.
Type
TreeNode

softRemove() → {TreeNode}

Mark this node as "removed" without actually removing it. Expand/show methods will never reveal this node until restored.
Source:
Returns:
Node object.
Type
TreeNode

state(obj, val) → {boolean|object}

Get or set a state value. This is a base method and will not invoke related changes, for example setting selected=false will not trigger any deselection logic.
Parameters:
Name Type Description
obj string | object Property name or Key/Value state object.
val boolean New value, if setting.
Source:
Returns:
Old state object, or old value if property name used.
Type
boolean | object

states(names, newVal) → {Array}

Get or set multiple state values to a single value.
Parameters:
Name Type Description
names Array Property names.
newVal boolean New value, if setting.
Source:
Returns:
Array of state booleans
Type
Array

swap(node) → {TreeNode}

Swap position with the given node.
Parameters:
Name Type Description
node TreeNode Node.
Source:
Returns:
Node objects.
Type
TreeNode

toggleCheck() → {TreeNode}

Toggle checked state.
Source:
Returns:
Node object.
Type
TreeNode

toggleCollapse() → {TreeNode}

Toggle collapsed state.
Source:
Returns:
Node object.
Type
TreeNode

toggleEditing() → {TreeNode}

Toggle editing state.
Source:
Returns:
Node object.
Type
TreeNode

toggleSelect() → {TreeNode}

Toggle selected state.
Source:
Returns:
Node object.
Type
TreeNode

toObject(excludeChildren, includeState) → {object}

Export this node as a native Object.
Parameters:
Name Type Default Description
excludeChildren boolean false Exclude children.
includeState boolean false Include itree.state object.
Source:
Returns:
Node object.
Type
object

toString() → {string}

Get the text content of this tree node.
Source:
Returns:
Text content.
Type
string

tree() → {InspireTree}

Get the tree this node ultimately belongs to.
Source:
Returns:
Tree instance.
Type
InspireTree

uncheck(shallow) → {TreeNode}

Uncheck this node.
Parameters:
Name Type Description
shallow boolean Skip auto-unchecking children.
Source:
Returns:
Node object.
Type
TreeNode

visible() → {boolean}

Get whether node is visible to a user. Returns false if it's hidden, or if any ancestor is hidden or collapsed.
Source:
Returns:
Whether visible.
Type
boolean