Class: FancytreeNode

FancytreeNode(parent, obj)

A FancytreeNode represents the hierarchical data model and operations.

Constructor

new FancytreeNode(parent, obj)

Creates a new FancytreeNode

Parameters:
Name Type Description
parent FancytreeNode
obj NodeData
Properties:
Name Type Description
tree Fancytree

The tree instance

parent FancytreeNode

The parent node

key string

Node id (must be unique inside the tree)

title string

Display name (may contain HTML)

data object

Contains all extra data that was passed on node creation

children Array.<FancytreeNode> | null | undefined

Array of child nodes.

For lazy nodes, null or undefined means 'not yet loaded'. Use an empty array
to define a node that has no children.

expanded boolean

Use isExpanded(), setExpanded() to access this property.

extraClasses string

Additional CSS classes, added to the node's &lt;span>.

Note: use node.add/remove/toggleClass() to modify.

folder boolean

Folder nodes have different default icons and click behavior.

Note: Also non-folders may have children.

statusNodeType string

null for standard nodes. Otherwise type of special system node: 'error', 'loading', 'nodata', or 'paging'.

lazy boolean

True if this node is loaded on demand, i.e. on first expansion.

selected boolean

Use isSelected(), setSelected() to access this property.

tooltip string

Alternative description used as hover popup

iconTooltip string

Description used as hover popup for icon. @since 2.27

type string

Node type, used with tree.types map. @since 2.27

Source:

Method Summary

Return Type Name and Arguments Details
FancytreeNode addChildren(children, insertBefore)

Append (or insert) a list of child nodes.

Details
void addClass(className)

Add class to node's span tag and to .extraClasses.

Details
FancytreeNode addNode(node, mode=child)

Append or prepend a node, or append a child node.

This a convenience function that calls addChildren()

Details
void addPagingNode(node, mode='child')

Add child status nodes that indicate 'More...', etc.

This also maintains the node's partload property.

Details
FancytreeNode appendSibling(node)

Append new node after this.

This a convenience function that calls addNode(node, 'after')

Details
$.Promise applyPatch(patch)

Modify existing child nodes.

Details
$.Promise collapseSiblings()

Collapse all sibling nodes.

Details
FancytreeNode copyTo(node, mode=child, map)

Copy this node as sibling or child of node.

Details
int countChildren(deep=true)

Count direct and indirect children.

Details
void debug(msg)

Write to browser console if debugLevel >= 4 (prepending node info)

Details
void discard()

Deprecated.

Details
void discardMarkup(includeSelf=false)

Remove DOM elements for all descendents. May be called on .collapse event
to keep the DOM small.

Details
void editCreateNode(mode='child', init)

[ext-edit] Create a new child or sibling node and start edit mode.

Details
void editEnd(applyChanges=false)

[ext-edit] Stop inline editing.

Details
void editStart()

[ext-edit] Start inline editing of current node title.

Details
void error(msg)

Write error to browser console if debugLevel >= 1 (prepending tree info)

Details
Array. findAll(match)

Find all nodes that match condition (excluding self).

Details
FancytreeNode findFirst(match)

Find first node that matches condition (excluding self).

Details
FancytreeNode findRelatedNode(where)

Find a node relative to self.

Details
void fixSelection3AfterClick()

Fix selection status, after this node was (de)selected in multi-hier mode.
This includes (de)selecting all children.

Details
void fixSelection3FromEndNodes()

Fix selection status for multi-hier mode.
Only end-nodes are considered to update the descendants branch and parents.
Should be called after this node has loaded new children or after
children have been modified using the API.

Details
void fromDict(dict)

Update node data. If dict contains 'children', then also replace
the hole sub tree.

Details
Array. | undefined getChildren()

Return the list of child nodes (undefined for unexpanded lazy nodes).

Details
Array. | null getCloneList(includeSelf=false)

[ext-clones] Return a list of clone-nodes (i.e. same refKey) or null.

Details
FancytreeNode | null getFirstChild()

Return the first child node or null.

Details
int getIndex()

Return the 0-based child index.

Details
string getIndexHier(separator=".", digits=1)

Return the hierarchical child index (1-based, e.g. '3.2.4').

Details
string getKeyPath(excludeSelf=false)

Return the parent keys separated by options.keyPathSeparator, e.g. "/id_1/id_17/id_32".

(Unlike node.getPath(), this method prepends a "/" and inverts the first argument.)

Details
FancytreeNode | null getLastChild()

Return the last child of this node or null.

Details
int getLevel()

Return node depth. 0: System root node, 1: visible top-level node, 2: first sub-level, ... .

Details
FancytreeNode | null getNextSibling()

Return the successor node (under the same parent) or null.

Details
FancytreeNode | null getParent()

Return the parent node (null for the system root node).

Details
Array. getParentList(includeRoot=false, includeSelf=false)

Return an array of all parent nodes (top-down).

Details
string getPath(includeSelf=true, part="title", separator="/")

Return a string representing the hierachical node path, e.g. "a/b/c".

Details
FancytreeNode | null getPrevSibling()

Return the predecessor node (under the same parent) or null.

Details
Array. getSelectedNodes(stopOnParents=false)

Return an array of selected descendant nodes.

Details
boolean | undefined hasChildren()

Return true if node has children. Return undefined if not sure, i.e. the node is lazy and not yet loaded).

Details
boolean hasFocus()

Return true if node has keyboard focus.

Details
void info(msg)

Write to browser console if debugLevel >= 3 (prepending node info)

Details
boolean isActive()

Return true if node is active (see also FancytreeNode#isSelected).

Details
boolean isBelowOf(otherNode)

Return true if node is vertically below otherNode, i.e. rendered in a subsequent row.

Details
boolean isChildOf(otherNode)

Return true if node is a direct child of otherNode.

Details
boolean isClone()

[ext-clones] Return true if this node has at least another clone with same refKey.

Details
boolean isDescendantOf(otherNode)

Return true, if node is a direct or indirect sub node of otherNode.

Details
Boolean isEditing()

[ext-edit] Check if this node is in edit mode.

Details
boolean isExpanded()

Return true if node is expanded.

Details
boolean isFirstSibling()

Return true if node is the first node of its parent's children.

Details
boolean isFolder()

Return true if node is a folder, i.e. has the node.folder attribute set.

Details
boolean isLastSibling()

Return true if node is the last node of its parent's children.

Details
boolean isLazy()

Return true if node is lazy (even if data was already loaded)

Details
boolean isLoaded()

Return true if node is lazy and loaded. For non-lazy nodes always return true.

Details
boolean isLoading()

Return true if children are currently beeing loaded, i.e. a Ajax request is pending.

Details
Boolean isMatched()

[ext-filter] Return true if this node is matched by current filter (or no filter is active).

Details
boolean isPagingNode()

Return true if this node is a status node of type 'paging'.

Details
boolean isPartload()

(experimental) Return true if this is partially loaded.

Details
boolean isPartsel()

Return true if node is partially selected (tri-state).

Details
boolean isRootNode()

Return true if this is the (invisible) system root node.

Details
boolean isSelected()

Return true if node is selected, i.e. has a checkmark set (see also FancytreeNode#isActive).

Details
boolean isStatusNode()

Return true if this node is a temporarily generated system node like
'loading', 'paging', or 'error' (node.statusNodeType contains the type).

Details
boolean isTopLevel()

Return true if this a top level node, i.e. a direct child of the (invisible) system root node.

Details
boolean isUndefined()

Return true if node is lazy and not yet loaded. For non-lazy nodes always return false.

Details
boolean isVisible()

Return true if all parent nodes are expanded. Note: this does not check
whether the node is scrolled into the visible part of the screen.

Details
void lazyLoad()

Deprecated.

Details
$.Promise load(forceReload=false)

Load all children of a lazy node if neccessary. The expanded state is maintained.

Details
$.Promise makeVisible(opts)

Expand all parents and optionally scroll into visible area as neccessary.
Promise is resolved, when lazy loading and animations are done.

Details
void moveTo(targetNode, mode, map)

Move this node to targetNode.

Details
$.Promise navigate(where, activate=true)

Set focus relative to this node and optionally activate.

Details
void remove()

Remove this node (not allowed for system root).

Details
void removeChild(childNode)

Remove childNode from list of direct children.

Details
void removeChildren()

Remove all child nodes and descendents. This converts the node into a leaf.

If this was a lazy node, it is still considered 'loaded'; call node.resetLazy()
in order to trigger lazyLoad on next expand.

Details
void removeClass(className)

Remove class from node's span tag and .extraClasses.

Details
void render(force=false, deep=false)

This method renders and updates all HTML markup that is required
to display this node in its current state.

Note:


  • It should only be neccessary to call this method after the node object
    was modified by direct access to its properties, because the common
    API methods (node.setTitle(), moveTo(), addChildren(), remove(), ...)
    already handle this.
  • FancytreeNode#renderTitle and FancytreeNode#renderStatus
    are implied. If changes are more local, calling only renderTitle() or
    renderStatus() may be sufficient and faster.
Details
void renderStatus()

Update element's CSS classes according to node state.

Details
void renderTitle()

Create HTML markup for the node's outer <span> (expander, checkbox, icon, and title).
Implies FancytreeNode#renderStatus.

Details
void replaceWith(source)

(experimental) Replace this node with source.
(Currently only available for paging nodes.)

Details
boolean reRegister(key, refKey)

[ext-clones] Update key and/or refKey for an existing node.

Details
void resetLazy()

Remove all children, collapse, and set the lazy-flag, so that the lazyLoad
event is triggered on next expand.

Details
void scheduleAction(mode, ms)

Schedule activity for delayed execution (cancel any pending request).
scheduleAction('cancel') will only cancel a pending request (if any).

Details
$.Promise scrollIntoView(effects=false, options=null) Details
$.Promise setActive(flag=true, opts)

Activate this node.

The cell option requires the ext-table and ext-ariagrid extensions.

Details
$.Promise setExpanded(flag=true, opts)

Expand or collapse this node. Promise is resolved, when lazy loading and animations are done.

Details
void setFocus(flag=true)

Set keyboard focus to this node.

Details
boolean setRefKey(refKey)

[ext-clones] Define a refKey for an existing node.

Details
void setSelected(flag=true, opts)

Select this node, i.e. check the checkbox.

Details
void setStatus(status, message, details)

Mark a lazy node as 'error', 'loading', 'nodata', or 'ok'.

Details
void setTitle(title)

Rename this node.

Details
void sortChildren(cmp, deep=false)

Sort child list by title.

Details
NodeData toDict(recursive=false, callback)

Convert node (or whole branch) into a plain object.

The result is compatible with node.addChildren().

Details
boolean toggleClass(className, flag)

Set, clear, or toggle class of node's span tag and .extraClasses.

Details
void toggleExpanded()

Flip expanded status.

Details
void toggleSelected()

Flip selection status.

Details
void triggerModify(operation, extra)

Trigger modifyChild event on node.parent(!).

Details
void triggerModifyChild(operation, childNode, extra)

Trigger modifyChild event on a parent to signal that a child was modified.

Details
void updateCounters()

[ext-childcounter] Update counter badges for node and its parents.
May be called in the loadChildren event, to update parents of lazy loaded
nodes.

Details
boolean visit(fn, includeSelf=false)

Call fn(node) for all child nodes in hierarchical order (depth-first).

Stop iteration, if fn() returns false. Skip current branch, if fn() returns "skip".

Return false if iteration was stopped.

Details
$.Promise visitAndLoad(fn, includeSelf=false)

Call fn(node) for all child nodes and recursively load lazy children.

Note: If you need this method, you probably should consider to review
your architecture! Recursivley loading nodes is a perfect way for lazy
programmers to flood the server with requests ;-)

Details
boolean visitParents(fn, includeSelf=false)

Call fn(node) for all parent nodes, bottom-up, including invisible system root.

Stop iteration, if fn() returns false.

Return false if iteration was stopped.

Details
boolean visitSiblings(fn, includeSelf=false)

Call fn(node) for all sibling nodes.

Stop iteration, if fn() returns false.

Return false if iteration was stopped.

Details
void warn(msg)

Write warning to browser console if debugLevel >= 2 (prepending node info)

Details

Method Details

addChildren(children, insertBeforeopt) → {FancytreeNode}

Append (or insert) a list of child nodes.

Parameters:
Name Type Attributes Description
children Array.<NodeData>

array of child node definitions (also single child accepted)

insertBefore FancytreeNode | string | Integer <optional>

child node (or key or index of such).
If omitted, the new children are appended.

Source:
See:
Returns:

first child added

Type
FancytreeNode

addClass(className)

Add class to node's span tag and to .extraClasses.

Parameters:
Name Type Description
className string

class name

Since:
  • 2.17
Source:

addNode(node, modeopt) → {FancytreeNode}

Append or prepend a node, or append a child node.

This a convenience function that calls addChildren()

Parameters:
Name Type Attributes Default Description
node NodeData

node definition

mode string <optional>
child

'before', 'after', 'firstChild', or 'child' ('over' is a synonym for 'child')

Source:
Returns:

new node

Type
FancytreeNode

addPagingNode(node, modeopt)

Add child status nodes that indicate 'More...', etc.

This also maintains the node's partload property.

Parameters:
Name Type Attributes Default Description
node boolean | object

optional node definition. Pass false to remove all paging nodes.

mode string <optional>
'child'

'child'|firstChild'

Since:
  • 2.15
Source:

appendSibling(node) → {FancytreeNode}

Append new node after this.

This a convenience function that calls addNode(node, 'after')

Parameters:
Name Type Description
node NodeData

node definition

Source:
Returns:

new node

Type
FancytreeNode

applyPatch(patch) → {$.Promise}

Modify existing child nodes.

Parameters:
Name Type Description
patch NodePatch
Source:
See:
Returns:
Type
$.Promise

collapseSiblings() → {$.Promise}

Collapse all sibling nodes.

Source:
Returns:
Type
$.Promise

copyTo(node, modeopt, mapopt) → {FancytreeNode}

Copy this node as sibling or child of node.

Parameters:
Name Type Attributes Default Description
node FancytreeNode

source node

mode string <optional>
child

'before' | 'after' | 'child'

map function <optional>

callback function(NodeData) that could modify the new node

Source:
Returns:

new

Type
FancytreeNode

countChildren(deepopt) → {int}

Count direct and indirect children.

Parameters:
Name Type Attributes Default Description
deep boolean <optional>
true

pass 'false' to only count direct children

Source:
Returns:

number of child nodes

Type
int

debug(msg)

Write to browser console if debugLevel >= 4 (prepending node info)

Parameters:
Name Type Description
msg *

string or object or array of such

Source:

discard()

Deprecated.

Deprecated:
  • since 2014-02-16. Use resetLazy() instead.
Source:

discardMarkup(includeSelfopt)

Remove DOM elements for all descendents. May be called on .collapse event
to keep the DOM small.

Parameters:
Name Type Attributes Default Description
includeSelf boolean <optional>
false
Source:

editCreateNode(modeopt, initopt)

[ext-edit] Create a new child or sibling node and start edit mode.

Parameters:
Name Type Attributes Default Description
mode String <optional>
'child'

'before', 'after', or 'child'

init Object <optional>

NodeData (or simple title string)

Since:
  • 2.4
Source:
Requires:
  • module:jquery.fancytree.edit.js

editEnd(applyChangesopt)

[ext-edit] Stop inline editing.

Parameters:
Name Type Attributes Default Description
applyChanges Boolean <optional>
false

false: cancel edit, true: save (if modified)

Source:
Requires:
  • module:jquery.fancytree.edit.js

editStart()

[ext-edit] Start inline editing of current node title.

Source:
Requires:
  • module:Fancytree

error(msg)

Write error to browser console if debugLevel >= 1 (prepending tree info)

Parameters:
Name Type Description
msg *

string or object or array of such

Source:

findAll(match) → {Array.<FancytreeNode>}

Find all nodes that match condition (excluding self).

Parameters:
Name Type Description
match string | function

title string to search for, or a
callback function that returns true if a node is matched.

Source:
Returns:

array of nodes (may be empty)

Type
Array.<FancytreeNode>

findFirst(match) → {FancytreeNode}

Find first node that matches condition (excluding self).

Parameters:
Name Type Description
match string | function

title string to search for, or a
callback function that returns true if a node is matched.

Source:
See:
Returns:

matching node or null

Type
FancytreeNode

findRelatedNode(where) → {FancytreeNode}

Find a node relative to self.

Parameters:
Name Type Description
where number | string

The keyCode that would normally trigger this move,
or a keyword ('down', 'first', 'last', 'left', 'parent', 'right', 'up').

Since:
  • v2.31
Source:
Returns:
Type
FancytreeNode

fixSelection3AfterClick()

Fix selection status, after this node was (de)selected in multi-hier mode.
This includes (de)selecting all children.

Source:

fixSelection3FromEndNodes()

Fix selection status for multi-hier mode.
Only end-nodes are considered to update the descendants branch and parents.
Should be called after this node has loaded new children or after
children have been modified using the API.

Source:

fromDict(dict)

Update node data. If dict contains 'children', then also replace
the hole sub tree.

Parameters:
Name Type Description
dict NodeData
Source:
See:

getChildren() → {Array.<FancytreeNode>|undefined}

Return the list of child nodes (undefined for unexpanded lazy nodes).

Source:
Returns:
Type
Array.<FancytreeNode> | undefined

getCloneList(includeSelfopt) → {Array.<FancytreeNode>|null}

[ext-clones] Return a list of clone-nodes (i.e. same refKey) or null.

Parameters:
Name Type Attributes Default Description
includeSelf boolean <optional>
false
Source:
Requires:
  • module:jquery.fancytree.clones.js
Returns:
Type
Array.<FancytreeNode> | null

getFirstChild() → {FancytreeNode|null}

Return the first child node or null.

Source:
Returns:
Type
FancytreeNode | null

getIndex() → {int}

Return the 0-based child index.

Source:
Returns:
Type
int

getIndexHier(separatoropt, digitsopt) → {string}

Return the hierarchical child index (1-based, e.g. '3.2.4').

Parameters:
Name Type Attributes Default Description
separator string <optional>
"."
digits int <optional>
1
Source:
Returns:
Type
string

getKeyPath(excludeSelfopt) → {string}

Return the parent keys separated by options.keyPathSeparator, e.g. "/id_1/id_17/id_32".

(Unlike node.getPath(), this method prepends a "/" and inverts the first argument.)

Parameters:
Name Type Attributes Default Description
excludeSelf boolean <optional>
false
Source:
See:
Returns:
Type
string

getLastChild() → {FancytreeNode|null}

Return the last child of this node or null.

Source:
Returns:
Type
FancytreeNode | null

getLevel() → {int}

Return node depth. 0: System root node, 1: visible top-level node, 2: first sub-level, ... .

Source:
Returns:
Type
int

getNextSibling() → {FancytreeNode|null}

Return the successor node (under the same parent) or null.

Source:
Returns:
Type
FancytreeNode | null

getParent() → {FancytreeNode|null}

Return the parent node (null for the system root node).

Source:
Returns:
Type
FancytreeNode | null

getParentList(includeRootopt, includeSelfopt) → {Array.<FancytreeNode>}

Return an array of all parent nodes (top-down).

Parameters:
Name Type Attributes Default Description
includeRoot boolean <optional>
false

Include the invisible system root node.

includeSelf boolean <optional>
false

Include the node itself.

Source:
Returns:
Type
Array.<FancytreeNode>

getPath(includeSelfopt, partopt, separatoropt) → {string}

Return a string representing the hierachical node path, e.g. "a/b/c".

Parameters:
Name Type Attributes Default Description
includeSelf boolean <optional>
true
part string | function <optional>
"title"

node property name or callback

separator string <optional>
"/"
Since:
  • v2.31
Source:
Returns:
Type
string

getPrevSibling() → {FancytreeNode|null}

Return the predecessor node (under the same parent) or null.

Source:
Returns:
Type
FancytreeNode | null

getSelectedNodes(stopOnParentsopt) → {Array.<FancytreeNode>}

Return an array of selected descendant nodes.

Parameters:
Name Type Attributes Default Description
stopOnParents boolean <optional>
false

only return the topmost selected
node (useful with selectMode 3)

Source:
Returns:
Type
Array.<FancytreeNode>

hasChildren() → {boolean|undefined}

Return true if node has children. Return undefined if not sure, i.e. the node is lazy and not yet loaded).

Source:
Returns:
Type
boolean | undefined

hasFocus() → {boolean}

Return true if node has keyboard focus.

Source:
Returns:
Type
boolean

info(msg)

Write to browser console if debugLevel >= 3 (prepending node info)

Parameters:
Name Type Description
msg *

string or object or array of such

Source:

isActive() → {boolean}

Return true if node is active (see also FancytreeNode#isSelected).

Source:
Returns:
Type
boolean

isBelowOf(otherNode) → {boolean}

Return true if node is vertically below otherNode, i.e. rendered in a subsequent row.

Parameters:
Name Type Description
otherNode FancytreeNode
Since:
  • 2.28
Source:
Returns:
Type
boolean

isChildOf(otherNode) → {boolean}

Return true if node is a direct child of otherNode.

Parameters:
Name Type Description
otherNode FancytreeNode
Source:
Returns:
Type
boolean

isClone() → {boolean}

[ext-clones] Return true if this node has at least another clone with same refKey.

Source:
Requires:
  • module:jquery.fancytree.clones.js
Returns:
Type
boolean

isDescendantOf(otherNode) → {boolean}

Return true, if node is a direct or indirect sub node of otherNode.

Parameters:
Name Type Description
otherNode FancytreeNode
Source:
Returns:
Type
boolean

isEditing() → {Boolean}

[ext-edit] Check if this node is in edit mode.

Source:
Requires:
  • module:jquery.fancytree.edit.js
Returns:

true if node is currently beeing edited

Type
Boolean

isExpanded() → {boolean}

Return true if node is expanded.

Source:
Returns:
Type
boolean

isFirstSibling() → {boolean}

Return true if node is the first node of its parent's children.

Source:
Returns:
Type
boolean

isFolder() → {boolean}

Return true if node is a folder, i.e. has the node.folder attribute set.

Source:
Returns:
Type
boolean

isLastSibling() → {boolean}

Return true if node is the last node of its parent's children.

Source:
Returns:
Type
boolean

isLazy() → {boolean}

Return true if node is lazy (even if data was already loaded)

Source:
Returns:
Type
boolean

isLoaded() → {boolean}

Return true if node is lazy and loaded. For non-lazy nodes always return true.

Source:
Returns:
Type
boolean

isLoading() → {boolean}

Return true if children are currently beeing loaded, i.e. a Ajax request is pending.

Source:
Returns:
Type
boolean

isMatched() → {Boolean}

[ext-filter] Return true if this node is matched by current filter (or no filter is active).

Since:
  • 2.13
Source:
Requires:
  • module:jquery.fancytree.filter.js
Returns:
Type
Boolean

isPagingNode() → {boolean}

Return true if this node is a status node of type 'paging'.

Since:
  • 2.15
Source:
Returns:
Type
boolean

isPartload() → {boolean}

(experimental) Return true if this is partially loaded.

Since:
  • 2.15
Source:
Returns:
Type
boolean

isPartsel() → {boolean}

Return true if node is partially selected (tri-state).

Since:
  • 2.23
Source:
Returns:
Type
boolean

isRootNode() → {boolean}

Return true if this is the (invisible) system root node.

Since:
  • 2.4
Source:
Returns:
Type
boolean

isSelected() → {boolean}

Return true if node is selected, i.e. has a checkmark set (see also FancytreeNode#isActive).

Source:
Returns:
Type
boolean

isStatusNode() → {boolean}

Return true if this node is a temporarily generated system node like
'loading', 'paging', or 'error' (node.statusNodeType contains the type).

Source:
Returns:
Type
boolean

isTopLevel() → {boolean}

Return true if this a top level node, i.e. a direct child of the (invisible) system root node.

Since:
  • 2.4
Source:
Returns:
Type
boolean

isUndefined() → {boolean}

Return true if node is lazy and not yet loaded. For non-lazy nodes always return false.

Source:
Returns:
Type
boolean

isVisible() → {boolean}

Return true if all parent nodes are expanded. Note: this does not check
whether the node is scrolled into the visible part of the screen.

Source:
Returns:
Type
boolean

lazyLoad()

Deprecated.

Deprecated:
  • since 2014-02-16: use load() instead.
Source:

load(forceReloadopt) → {$.Promise}

Load all children of a lazy node if neccessary. The expanded state is maintained.

Parameters:
Name Type Attributes Default Description
forceReload boolean <optional>
false

Pass true to discard any existing nodes before. Otherwise this method does nothing if the node was already loaded.

Source:
Returns:
Type
$.Promise

makeVisible(optsopt) → {$.Promise}

Expand all parents and optionally scroll into visible area as neccessary.
Promise is resolved, when lazy loading and animations are done.

Parameters:
Name Type Attributes Description
opts object <optional>

passed to setExpanded().
Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}

Source:
Returns:
Type
$.Promise

moveTo(targetNode, mode, mapopt)

Move this node to targetNode.

Parameters:
Name Type Attributes Description
targetNode FancytreeNode
mode string
     'child': append this node as last child of targetNode.
              This is the default. To be compatble with the D'n'd
              hitMode, we also accept 'over'.
     'firstChild': add this node as first child of targetNode.
     'before': add this node as sibling before targetNode.
     'after': add this node as sibling after targetNode.
map function <optional>

optional callback(FancytreeNode) to allow modifcations

Source:

Set focus relative to this node and optionally activate.

Parameters:
Name Type Attributes Default Description
where number

The keyCode that would normally trigger this move,
e.g. $.ui.keyCode.LEFT would collapse the node if it
is expanded or move to the parent oterwise.

activate boolean <optional>
true
Source:
Returns:
Type
$.Promise

remove()

Remove this node (not allowed for system root).

Source:

removeChild(childNode)

Remove childNode from list of direct children.

Parameters:
Name Type Description
childNode FancytreeNode
Source:

removeChildren()

Remove all child nodes and descendents. This converts the node into a leaf.

If this was a lazy node, it is still considered 'loaded'; call node.resetLazy()
in order to trigger lazyLoad on next expand.

Source:

removeClass(className)

Remove class from node's span tag and .extraClasses.

Parameters:
Name Type Description
className string

class name

Since:
  • 2.17
Source:

render(forceopt, deepopt)

This method renders and updates all HTML markup that is required
to display this node in its current state.

Note:


  • It should only be neccessary to call this method after the node object
    was modified by direct access to its properties, because the common
    API methods (node.setTitle(), moveTo(), addChildren(), remove(), ...)
    already handle this.
  • FancytreeNode#renderTitle and FancytreeNode#renderStatus
    are implied. If changes are more local, calling only renderTitle() or
    renderStatus() may be sufficient and faster.
Parameters:
Name Type Attributes Default Description
force boolean <optional>
false

re-render, even if html markup was already created

deep boolean <optional>
false

also render all descendants, even if parent is collapsed

Source:

renderStatus()

Update element's CSS classes according to node state.

Source:
See:

renderTitle()

Create HTML markup for the node's outer <span> (expander, checkbox, icon, and title).
Implies FancytreeNode#renderStatus.

Source:
See:

replaceWith(source)

(experimental) Replace this node with source.
(Currently only available for paging nodes.)

Parameters:
Name Type Description
source Array.<NodeData>

List of child node definitions

Since:
  • 2.15
Source:

reRegister(key, refKey) → {boolean}

[ext-clones] Update key and/or refKey for an existing node.

Parameters:
Name Type Description
key string
refKey string
Source:
Requires:
  • module:jquery.fancytree.clones.js
Returns:
Type
boolean

resetLazy()

Remove all children, collapse, and set the lazy-flag, so that the lazyLoad
event is triggered on next expand.

Source:

scheduleAction(mode, ms)

Schedule activity for delayed execution (cancel any pending request).
scheduleAction('cancel') will only cancel a pending request (if any).

Parameters:
Name Type Description
mode string
ms number
Source:

scrollIntoView(effectsopt, optionsopt) → {$.Promise}

Parameters:
Name Type Attributes Default Description
effects boolean | PlainObject <optional>
false

animation options.

options object <optional>
null

{topNode: null, effects: ..., parent: ...} this node will remain visible in
any case, even if this is outside the scroll pane.

Source:
Returns:
Type
$.Promise

setActive(flagopt, optsopt) → {$.Promise}

Activate this node.

The cell option requires the ext-table and ext-ariagrid extensions.

Parameters:
Name Type Attributes Default Description
flag boolean <optional>
true

pass false to deactivate

opts object <optional>

additional options. Defaults to {noEvents: false, noFocus: false, cell: null}

Source:
Returns:
Type
$.Promise

setExpanded(flagopt, optsopt) → {$.Promise}

Expand or collapse this node. Promise is resolved, when lazy loading and animations are done.

Parameters:
Name Type Attributes Default Description
flag boolean <optional>
true

pass false to collapse

opts object <optional>

additional options. Defaults to {noAnimation: false, noEvents: false}

Source:
Returns:
Type
$.Promise

setFocus(flagopt)

Set keyboard focus to this node.

Parameters:
Name Type Attributes Default Description
flag boolean <optional>
true

pass false to blur

Source:
See:

setRefKey(refKey) → {boolean}

[ext-clones] Define a refKey for an existing node.

Parameters:
Name Type Description
refKey string
Since:
  • 2.16
Source:
Requires:
  • module:jquery.fancytree.clones.js
Returns:
Type
boolean

setSelected(flagopt, optsopt)

Select this node, i.e. check the checkbox.

Parameters:
Name Type Attributes Default Description
flag boolean <optional>
true

pass false to deselect

opts object <optional>

additional options. Defaults to {noEvents: false, p
propagateDown: null, propagateUp: null, callback: null }

Source:

setStatus(status, messageopt, detailsopt)

Mark a lazy node as 'error', 'loading', 'nodata', or 'ok'.

Parameters:
Name Type Attributes Description
status string

'error'|'empty'|'ok'

message string <optional>
details string <optional>
Source:

setTitle(title)

Rename this node.

Parameters:
Name Type Description
title string
Source:

sortChildren(cmpopt, deepopt)

Sort child list by title.

Parameters:
Name Type Attributes Default Description
cmp function <optional>

custom compare function(a, b) that returns -1, 0, or 1 (defaults to sort by title).

deep boolean <optional>
false

pass true to sort all descendant nodes

Source:

toDict(recursiveopt, callbackopt) → {NodeData}

Convert node (or whole branch) into a plain object.

The result is compatible with node.addChildren().

Parameters:
Name Type Attributes Default Description
recursive boolean <optional>
false

include child nodes

callback function <optional>

callback(dict, node) is called for every node, in order to allow modifications

Source:
Returns:
Type
NodeData

toggleClass(className, flagopt) → {boolean}

Set, clear, or toggle class of node's span tag and .extraClasses.

Parameters:
Name Type Attributes Description
className string

class name (separate multiple classes by space)

flag boolean <optional>

true/false to add/remove class. If omitted, class is toggled.

Since:
  • 2.17
Source:
Returns:

true if a class was added

Type
boolean

toggleExpanded()

Flip expanded status.

Source:

toggleSelected()

Flip selection status.

Source:

triggerModify(operation, extraopt)

Trigger modifyChild event on node.parent(!).

Parameters:
Name Type Attributes Description
operation string

Type of change: 'add', 'remove', 'rename', 'move', 'data', ...

extra object <optional>
Source:

triggerModifyChild(operation, childNodeopt, extraopt)

Trigger modifyChild event on a parent to signal that a child was modified.

Parameters:
Name Type Attributes Description
operation string

Type of change: 'add', 'remove', 'rename', 'move', 'data', ...

childNode FancytreeNode <optional>
extra object <optional>
Source:

updateCounters()

[ext-childcounter] Update counter badges for node and its parents.
May be called in the loadChildren event, to update parents of lazy loaded
nodes.

Source:
Requires:
  • module:jquery.fancytree.childcounters.js

visit(fn, includeSelfopt) → {boolean}

Call fn(node) for all child nodes in hierarchical order (depth-first).

Stop iteration, if fn() returns false. Skip current branch, if fn() returns "skip".

Return false if iteration was stopped.

Parameters:
Name Type Attributes Default Description
fn function

the callback function.
Return false to stop iteration, return "skip" to skip this node and
its children only.

includeSelf boolean <optional>
false
Source:
Returns:
Type
boolean

visitAndLoad(fnopt, includeSelfopt) → {$.Promise}

Call fn(node) for all child nodes and recursively load lazy children.

Note: If you need this method, you probably should consider to review
your architecture! Recursivley loading nodes is a perfect way for lazy
programmers to flood the server with requests ;-)

Parameters:
Name Type Attributes Default Description
fn function <optional>

optional callback function.
Return false to stop iteration, return "skip" to skip this node and
its children only.

includeSelf boolean <optional>
false
Since:
  • 2.4
Source:
Returns:
Type
$.Promise

visitParents(fn, includeSelfopt) → {boolean}

Call fn(node) for all parent nodes, bottom-up, including invisible system root.

Stop iteration, if fn() returns false.

Return false if iteration was stopped.

Parameters:
Name Type Attributes Default Description
fn function

the callback function.
Return false to stop iteration, return "skip" to skip this node and children only.

includeSelf boolean <optional>
false
Source:
Returns:
Type
boolean

visitSiblings(fn, includeSelfopt) → {boolean}

Call fn(node) for all sibling nodes.

Stop iteration, if fn() returns false.

Return false if iteration was stopped.

Parameters:
Name Type Attributes Default Description
fn function

the callback function.
Return false to stop iteration.

includeSelf boolean <optional>
false
Source:
Returns:
Type
boolean

warn(msg)

Write warning to browser console if debugLevel >= 2 (prepending node info)

Parameters:
Name Type Description
msg *

string or object or array of such

Source:

Fork me on GitHub