If your chart represents a tree structure, you might want to collapse a sub-tree starting from a node or expand a sub-tree that was previously collapsed. Use the setExpanded method of a node to do this programmatically. You can also invoke the setExpandable method to show a +/- button beside the node; using this button the user will be able to collapse and expand the sub-tree, which has the specified node as root. To check if a sub-tree is expanded or collapsed call the getExpanded method.
If the Expandable attribute of a node is set to true, there is a [±] button displayed beside the node to allow users to collapse or expand the tree branch starting there. The button location can be customized through the diagram's setExpandButtonPosition method. The appearance of the collapse / expand icon can be customized by setting Renderers.ExpandIconRenderer. By default, pressing that button automatically collapses or expands the tree branch and raises the treeExpanded or treeCollapsed events.
A node can be connected to other nodes through outgoing and incoming links. You can call the setExpandOnIncoming method to specify which items connected to a node will be regarded as its descendants. If you pass false (default value) then each node will be regarded as a parent of its outgoing links and the items attached to them. If you pass true, the node' incoming links will define its children. Thus this property specifies the parent-children relationship between chart items and respectively the overall direction in which collapsing / expanding is done.
Use the setRecursiveExpand method to specify whether the whole sub-tree starting from a node will be shown when expanding, or only the first level of descendants.
The setExpandButtonAction method lets you override the standard functionality of the [±] button. Set this property to RaiseEvents and handle the expandButtonClicked event if you need to implement your own expand/collapse logic.