Methods
addNode(parent, index, label, context, callback)
// Add a node as a child of the parent node with the
// given label (optional) and at the given index.
// context is arbitrary additional information that can be used in creating the new node
// In the callback function child is the node that was added. If child is false try again.
// If child is null then add failed - node is removed.
// Index is the position the node was actually inserted at.
Parameters:
Name |
Type |
Description |
parent |
|
|
index |
|
|
label |
|
|
context |
|
|
callback |
|
|
allowAdd(n, operation, childrenopt) → {boolean}
Check if the node allows adding children to it.
Returns true if the node allows children to be added to it.
If the children parameter is passed in return true if each of those children
(or ones just like them) can be added. Children is an array of nodes.
operation is "add" when adding a new node (addNode will be called),
"move" when the node comes from elsewhere in the tree and is being moved (moveNodes will be called),
and "copy" when the node is a copy of a node from elsewhere in the tree (copyNodes will be called).
additional operation values are possible if the adapter supports custom drag operations.
Parameters:
Name |
Type |
Attributes |
Description |
n |
treeNodeAdapter.node
|
|
The node to check if adding children is allowed. |
operation |
string
|
|
Specifies how the node would be added. One of "add", "move", "copy" or a custom value. |
children |
Array.<treeNodeAdapter.node>
|
<optional>
|
The children to be added. |
Returns:
true if children can be added and false otherwise.
-
Type
-
boolean
allowDelete(n) → {boolean}
Return true if the given node can be deleted.
Parameters:
Returns:
true if the node can be deleted and false otherwise.
-
Type
-
boolean
allowDrag(n) → {boolean}
Return true if the given node can be dragged.
Parameters:
Returns:
true if the node can be dragged and false otherwise.
-
Type
-
boolean
allowRename(n) → {boolean}
Return true if the given node can be renamed.
Parameters:
Returns:
true if the node can be renamed and false otherwise.
-
Type
-
boolean
Return the ith child of the given node.
Parameters:
Name |
Type |
Description |
n |
treeNodeAdapter.node
|
The node from which to get the child node. |
i |
integer
|
The index of the child to return. |
Returns:
The child node. If the node has no children or no child at index i then
undefined is returned.
-
Type
-
treeNodeAdapter.node
childCount(n) → (nullable) {number}
Returns the number of children that the given node has or null if the answer is not yet known, which
can happen for lazy loaded nodes.
Parameters:
Returns:
The number of children or null if unknown.
-
Type
-
number
copyNodes(parent, index, nodes, callback)
copyNodes: function(parent, index, children, function(places)), // copies one or more nodes from elsewhere in the
// tree to be children of parent starting at index among the existing children of parent. A copy of each node
// and all its descendants is made. The copies are the same except for identity and parentage.
// When the nodes have been copied the callback function is called with a places array of indexes where the
// children nodes ended up. If the tree nodes are sorted then even though they were copied starting at the
// given index they could end up at any position. If the tree nodes are not sorted then places will consist
// of integers index ... index + n - 1 where n is the number of children. If the move fails return false
// for places. If some of the nodes can't be moved return -1 for its index in places.
Parameters:
Name |
Type |
Description |
parent |
|
|
index |
|
|
nodes |
|
|
callback |
|
|
deleteNode(n, callback, more)
deleteNode: function(n, function(status), more), // Called in response to DEL key. Delete node n then call fn with true to delete
// the tree node or false to cancel the delete.
// If more is true another deleteNode call will be made right away. The more argument can be ignored or can
// be used to batch up requests to the server. In either case each call back must be made.
Parameters:
Name |
Type |
Description |
n |
|
|
callback |
|
|
more |
|
|
dragOperations(Array) → {Object}
Determine which operations are allowed while dragging the given array of nodes.
Return an object with allowed drag operations.
The properties are: "normal", "ctrl", "alt", "shift", "meta".
The standard values are "move", "copy" or "add". Other values are allowed.
The normal property is required.
The default is: { normal: "move", ctrl: "copy" } or if nodes is null { normal: "add" }
Parameters:
Name |
Type |
Description |
Array |
Array.<treeNodeAdapter.node>
|
of nodes being dragged or null when dragging from an external source. |
Returns:
Allowed drag operations as described above.
-
Type
-
Object
fetchChildNods(n, callback)
Fetch child nodes for the given node from a server (or by any other asynchronous means).
This method is optional. This is used for asynchronous/lazy tree construction. The root and first level of nodes
should not be lazy loaded. May be called after child count returns null.
Parameters:
Name |
Type |
Description |
n |
treeNodeAdapter.node
|
The node for which to fetch children. |
callback |
function
|
function(status) This function must be called when the
asynchronous operation has completed and nodes have been added to the model. The status is:
- > 0 (or true) if 1 or more children were fetched.
- 0 if the node has 0 children.
- false if there was an error fetching the children.
|
getClasses(n) → {string}
Returns one or more CSS classes to add to the node content container or null if none. Multiple
classes are separated by a space. This is an optional method.
If the method doesn't exist then no nodes will have classes added to the node content container.
Parameters:
Returns:
The node's CSS Classes.
-
Type
-
string
getIcon(n) → {string}
Returns the icon of the node or null if none. The icon is a CSS class name.
The icon is used by node content rendering. This is an optional method.
If the method doesn't exist then no nodes will have icons.
Parameters:
Returns:
The node's icon.
-
Type
-
string
getLabel(n) → {string}
Returns the label of the given node. The label is used by node content rendering (if renderNodeContent not
implemented) and for editing during rename.
Parameters:
Returns:
The node's label.
-
Type
-
string
getLink(n) → {string}
Returns the URL to navigate to when the node is activated.
This is an optional method. It is only needed for navigation trees.
If defined it is called during activation if treeView.navigation option is true.
Parameters:
Returns:
The node's link URL.
-
Type
-
string
hasChildren(n) → (nullable) {boolean}
Returns true if the node has children, false if it does not and null if not yet known.
Parameters:
Returns:
true if the node has children, false if it does not and null if not yet known.
-
Type
-
boolean
isDisabled(n) → {boolean}
Returns the disabled state of a node.
A disabled node cannot be selected or activated but it can be focused.
This is an optional method. If not defined no nodes are ever disabled.
Parameters:
Returns:
true if the node is disabled and false otherwise.
-
Type
-
boolean
moveNodes(parent, index, nodes, callback)
moveNodes: function(parent, index, children, function(places)), // moves one or more nodes from elsewhere in the
// tree to be children of parent starting at index among the existing children of parent. The move includes
// all the descendants of the moved nodes. Only the parents and/or positions of the moved nodes should change.
// When the nodes have been moved the callback function is called with a places array of indexes where the
// children nodes ended up. If the tree nodes are sorted then even though they were moved starting at the
// given index they could end up at any position. If the tree nodes are not sorted then places will consist
// of integers index ... index + n - 1 where n is the number of children. If the move fails return false
// for places. If some of the nodes can't be moved return -1 for its index in places. *
Parameters:
Name |
Type |
Description |
parent |
|
|
index |
|
|
nodes |
|
|
callback |
|
|
renameNode(n, newLabel, callback)
Rename a node. n is the node to rename with newLabel.
// In the callback node is the renamed node (most likely the same)
// If node is false try again.
// If node is null then rename failed return to previous value.
// Index is the new position the node is in after rename.
Parameters:
Name |
Type |
Description |
n |
|
|
newLabel |
|
|
callback |
|
|
renderNodeContent(n, out, options, state)
This is an optional function used to render the node content.
It is used for advanced cases where more control over the node markup is needed.
The content must include an element with tabindex='-1' and that element must have a class that matches
the treeView.labelClass option. The custom rendering is responsible for setting the
aria-level, aria-disabled, aria-selected, and aria-expanded attributes for proper accessibility.
The options and state arguments provide additional information to determine how to render the node.
Parameters:
Name |
Type |
Description |
n |
treeNodeAdapter.node
|
The node from which to get the disabled state. |
out |
apex.util.htmlBuilder
|
|
options |
Object
|
View options.
Properties
Name |
Type |
Description |
iconType |
string
|
|
labelClass |
string
|
|
useLinks |
boolean
|
|
|
state |
Object
|
Node state information.
Properties
Name |
Type |
Description |
selected |
boolean
|
|
level |
integer
|
|
disabled |
boolean
|
|
hasChildren |
boolean
|
|
expanded |
boolean
|
|
|
Returns the root node of the tree. All trees must have a single root node even if it is not
shown/used.
Returns:
The root node.
-
Type
-
treeNodeAdapter.node
Type Definitions
defaultNode
Type:
Properties:
Name |
Type |
Attributes |
Description |
label |
string
|
|
The node label returned by getLabel. |
id |
string
|
<optional>
|
The node identity. This property is required if the hasIdentity argument to
treeView.makeDefaultNodeAdapter is true. xxx |
type |
string
|
<optional>
|
The type of the node. xxx |
link |
string
|
<optional>
|
The URL returned by getLink. |
children |
Array.<treeNodeAdapter.defaultNode>
|
<optional>
|
The nodes children. Empty array means that
it could have children but doesn't. Omit for leaf nodes. The getChild method is used to
access the nodes children. |
icon |
string
|
<optional>
|
The icon CSS class returned by getIcon. This overrides any icon
based on the node type. |
classes |
string
|
<optional>
|
The classes returned by getClasses. These are added to any classes
based on node type. |
isDisabled |
boolean
|
<optional>
|
The disabled state returned by isDisabled. This overrides any
disabled state based on node type. |
operations |
object
|
<optional>
|
xxx |
_parent |
treeNodeAdapter.defaultNode
|
|
This is a reference to the parent node.
This is added automatically when the default adapter is created and should not be present in the
initial data. |
node
An object that represents a node in a tree data structure. There are no requirements for and no assumptions
are made about the specific properties of the object as all access to the node is through the
treeNodeAdapter interface.
Type:
typeInfo
xxx
Type:
Properties:
Name |
Type |
Attributes |
Description |
icon |
string
|
<optional>
|
xxx |
classes |
string
|
<optional>
|
|
isDisabled |
boolean
|
function
|
<optional>
|
|
defaultLabel |
string
|
<optional>
|
|
validChildren |
true
|
Array.<string>
|
<optional>
|
|
operations |
Object
|
<optional>
|
Properties
Name |
Type |
Attributes |
Description |
canAdd |
boolean
|
function
|
<optional>
|
|
canDelete |
boolean
|
function
|
<optional>
|
|
canRename |
boolean
|
function
|
<optional>
|
|
canDrag |
boolean
|
function
|
<optional>
|
|
drag |
Object
|
<optional>
|
An object that defines the operation to perform during a drop
based on the modifier key pressed. The properties are the modifier keys and can containe any one
of: "normal", "ctrl", "alt", "shift" and the values are the the operation to perform and can be
anyone of "move", "copy", or "add". The value can also be a custom operation that is handled
in the beforeStop event. |
externalDrag |
Object
|
<optional>
|
An object that defines the operation to perform during a drop
from an external draggable based on the modifier key pressed. The properties and values are the same as
for the operations drag property. This property can only be used on the "default" type. |
|