I’m using custom expand and collapse methods in the virtualized tree layout. When I collapse a node, the children of that node are hidden but the siblings of the collapsed node does not move up to fill the vacant space. I do remove the children from the diagram’s model and also call layoutDiagram(true). Expansion the leaf nodes bring the children dynamically to the model and the expanded node’s siblings move down to make room for the new children. So I’m confused as to why collapsing a node does not update the positions of the siblings.
Any ideas on what I can do to fix this issue?
Are you sure you want to call Diagram.layoutDiagram? I would think you would need to layout the whole model tree, not just what’s in the diagram.
That also means that the model data needs to know whether the node has been made not visible due to a *parent being collapsed.
I do set a property on the childrens’ data objects indicating whether or not it is hidden by a parent’s collapse. I exclude such nodes in the computeDocumentBounds() and also have a binding for the node’s visibility based on this property.
I was assuming that layoutDiagram() would reposition the nodes after a collapse. What other function do you recommend I use?
Ah, so you are using VirtualizedTreeLayout? OK, so the Diagram.layout is indeed the virtual layout, working on the whole model (not on the Diagram.model).
If you have added a property on the node data to indicate whether or not it should be visible, have you updated VirtualizedTreeNetwork.addData to know when to ignore node data?
Yes I did modify the addData to ignore such nodes. So instead of calling diagram.layoutDiagram I used the doLayout(diagram) which now repositions the sibling nodes. However now on expanding a node for the first time its children are not visible; only white space is visible instead of the new nodes.
I wonder if you need to call
Calling onViewportChanged didn’t make the new nodes visible. The nodes were added to the diagram.model collection and layoutDiagram was called too. Collapsing the node and then expanding it again makes the children visible. Any idea why this might be happening.
onViewportChanged should have worked. Check that the missing node data have the expected bounds and other properties.
It has the bounds properties. The code is the same as I had before I called the doLayout after a node is collapsed. Initially I had the option for only expanding nodes not collapsing them. So now I want to give collapse option also but the expansion seems to not work even though nothing related to the expansion was changed.
It’s strange that the visibility binding for the new node added during the expansion is not called even though the node is included in the model. What could be preventing the node from being displayed?
So for a particular node data, Diagram.findNodeForKey or Diagram.findNodeForData returns a Node and it is visible and has the expected actualBounds that is within the viewport?
If there is a parent link/node (if Node.findTreeParentNode returns a Node), perhaps the parent node is not Node.isTreeExpanded.
Setting isTreeExpanded to true fixed the issue.