-
-
Notifications
You must be signed in to change notification settings - Fork 39
Functions: Tree
Inserts a new child node to a parent node at the specified index.
- 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 to it at the specified index.
- If the parent does not have children, the method adds the child to the parent.
- If the index value is greater than or equal to the number of children in the parent, the method adds the child at the end of the children.
- newNode (Object): The new child node.
- index (number): The 0-based index of where to insert the child node. Defaults to 0 for negative index.
- parentNode (Node): The Node object that defines the parent node.
(boolean): Returns true on success, false otherwise.
Adds a 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.
(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.
(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.
(number): Returns the vertical scroll position, or -1 on error.
- value (number): An integer that 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.
(boolean): Returns true on success, false otherwise.
Toggles a node to display or hide its children.
- node (Node): The Node object.
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.