I’m new to GoJs. I’ve built an Org chart that has search functionality. When the user searches, all branches that contain a match are expanded to the match. When they hit the “clear” button, all branches should collapse. It does collapse down to the third level like I want it to, however the internal roots are still expanded. So if I open a branch, all of the internal branches that were opened on the previous search are still expanded.
Here’s the code right now:
function collapseAllNodes() {
var input = document.getElementById('mySearch');
if (input) input.value = ''; // clear anything out of the mySearch div
myDiagram.startTransaction('collapse all'); // Collaps roots
myDiagram.findTreeRoots().each(function (root) {
root.collapseTree(3); // Collapse until the third level
});
myDiagram.commitTransaction('collapse all');
}
Is there a way to iterate through and make sure every branch is closed completely? Please let me know if I need to clarify better. Thank you
Janae Fairbourn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.