OrgChart icon indicating copy to clipboard operation
OrgChart copied to clipboard

Programatically hide/show specific nodes (without remove/delete)

Open takuy opened this issue 6 years ago • 7 comments

Is there any way to programmatically collapse/expand specific nodes? I don't want to delete them, I just need a way to hide them until I decide to show them.

takuy avatar Feb 19 '19 14:02 takuy

https://rawgit.com/dabeng/OrgChart/master/demo/default-collapsed.html

CaptainCannabis avatar Feb 19 '19 15:02 CaptainCannabis

Hi @CaptainCannabis, not exactly. I don't want to have something collapsed by default - and not per branch.

If I have a tree expanded, I want just be able to programmatically, hide a specific node.

takuy avatar Feb 19 '19 21:02 takuy

The way i do it is by recursively iterating over the diagramm source - set collapse to true or false and then update the diagramm-div with the new source.

CaptainCannabis avatar Feb 20 '19 07:02 CaptainCannabis

Collapse only works on a parent node, not on children.

takuy avatar Feb 20 '19 20:02 takuy

Looking it further, this seems pretty doable as a PR. apply "hidden" to the node's parent-most

and then update the lines. I'll work on that at some point this week.

takuy avatar Feb 20 '19 20:02 takuy

I'm having a tough time seeing how the lines are hidden and shown with their nodes. All I see is that all lines disappear and then one magically appears (but I don't see how that happens?). @dabeng Any help would be appreciated.

takuy avatar Mar 02 '19 06:03 takuy

@dabeng Seconding this. It's really easy to hide children of a node, but not the node itself. If the node itself is the only child of course we can use hideChildren on the parent element, but if it has siblings the only option currently is to tediously remove lines. But as @takuy pointed out, it is very unclear on how lines are added/removed. A function hideBranch($node) to hide a node and all its children would be really nice to have!

Skatinger avatar Sep 29 '20 12:09 Skatinger