Need some info please.
I need to create a button with a text box .it should search the tree and display from that tree alone…
Rest all should be collapsed or hidden.
Is there any functionality exists,that can be used…or I need to try some logic implementation?
Have you seen the Org Chart sample, Org Chart Static ? It demonstrates searching the whole diagram.
To hide the rest of the diagram, which sounds as if it does not depend on the results of the search, I suggest you iterate over all of the Diagram.nodes and set each Node.visible if it is in the subtree of the selected node.
Something like:
var selected = myDiagram.selection.first();
if (selected == null) return;
myDiagram.startTransaction();
var subtree = selected.findTreeParts();
myDiagram.nodes.each(function(n) {
n.visible = subtree.contains(n);
});
myDiagram.commitTransaction("hid rest of tree outside of selected subtree");
I have modified my answer above to be clearer and faster.
Most of what you need is available on the Node class, Node | GoJS API.
Maybe you want to call Node | GoJS API – it takes an argument that specifies how many levels to leave visible.
Although you can call Node | GoJS API to find out the depth of a node in its tree, there is no efficient way to find the “deepest” level node. You should write that yourself, recursively walking the tree while keeping track of the levels.