-
-
Notifications
You must be signed in to change notification settings - Fork 39
Functions: Tree
- addChildNodes
- appendChildNode
- clear
- closeNode
- flattenChildNodes
- flattenNode
- getChildNodes
- getNodeById
- getOpenNodes
- getRootNode
- getSelectedNode
- insertNodeAfter
- insertNodeBefore
- loadData
- openNode
- removeChildNodes
- removeNode
- scrollToNode
- scrollTop
- selectNode
- toggleNode
- toString
- update
- updateNode
Adds an array of new child nodes to a parent node at the specified index.
- newNodes (Array): An array of new child nodes.
- [index] (number): The 0-based index of where to insert the child node.
- [parentNode] (Node): The Node object that defines the parent node.
(boolean): Returns true on success, false otherwise.
Adds a new child node to the end of the list of children of a specified parent node.
- If the parent is null or undefined, inserts the child at the specified index in the top-level.
- If the parent has children, the method adds the child as the last child.
- If the parent does not have children, the method adds the child to the parent.
- newNode (Object): The new child node.
- parentNode (Node): The Node object that defines the parent node.
(boolean): Returns true on success, false otherwise.
Clears the tree.
Closes a node to hide its children.
- node (Node): The Node object.
- [options={}] (Object): The options object.
- [options.silent=false] (boolean): Sets true to prevent "closeNode" event from being triggered.
(boolean): Returns true on success, false otherwise.
Flattens all child nodes of a parent node.
- parentNode (Node): The Node object that defines the parent node.
(Array): Returns an array of Node objects containing all the child nodes of the parent node.
Flattens a node.
- node (Node): The Node object.
(Array): Returns a flattened list of Node objects.
Gets a list of child nodes.
- parentNode (Node): The Node object that defines the parent node. If null or undefined, returns a list of top level nodes.
(Array): Returns an array of Node objects containing all the child nodes of the parent node.
Gets a node by its unique id. This assumes that you have given the nodes in the data a unique id.
- id (number|string): An unique node id. A null value will be returned if the id doesn't match.
(Node): Returns a Node object that matches the id, null otherwise.
Gets an array of open nodes.
(Array): Returns an array of Node objects containing open nodes.
(Node): Returns the root node, or null if empty.
(Node): Returns the selected node, or null if not selected.
Inserts the specified node after the reference node.
- newNode (Object): The new sibling node.
- referenceNode (Node): The Node object that defines the reference node.
(boolean): Returns true on success, false otherwise.
Inserts the specified node before the reference node.
- newNode (Object): The new sibling node.
- referenceNode (Node): The Node object that defines the reference node.
(boolean): Returns true on success, false otherwise.
Loads data in the tree.
- data (Object|Array): The data is an object or array of objects that defines the node.
Opens a node to display its children.
- node (Node): The Node object.
- [options={}] (Object): The options object.
- [options.silent=false] (boolean): Sets true to prevent "openNode" event from being triggered.
(boolean): Returns true on success, false otherwise.
Removes all child nodes from a parent node.
- parentNode (Node): The Node object that defines the parent node.
(boolean): Returns true on success, false otherwise.
Removes a node and all of its child nodes.
- node (Node): The Node object.
(boolean): Returns true on success, false otherwise.
Sets the current scroll position to this node.
- node (Node): The Node object.
(boolean): Returns true on success, false otherwise.
- [value] (number): If the value is specified, indicates the new position to set the scroll bar to.
(number): Returns the vertical scroll position.
Selects a node.
- node (Node): The Node object. If null or undefined, deselects the current node.
- [options={}] (Object): The options object.
- [options.silent=false] (boolean): Sets true to prevent "selectNode" event from being triggered.
(boolean): Returns true on success, false otherwise.
Toggles a node to display or hide its children.
- node (Node): The Node object.
- [options={}] (Object): The options object.
- [options.silent=false] (boolean): Sets true to prevent "closeNode", "openNode", and "selectNode" events from being triggered.
Serializes the current state of a node to a JSON string.
- node (Node): The Node object. If null, returns the whole tree.
(string): Returns a JSON string represented the tree.
Updates the tree.
Updates the data of a node.
- node (Node): The Node object.
- data (Object): The data object.