The node in the tree view shrinks

I use the “TreeExpanderButton” panel in the tree view node template to implement the expand / collapse button, and I want to display the first and second level nodes during initialization. The other nodes are collapsed. The third level and below nodes are only visible when the corresponding parent When the node can start.
I use visible: false control, but it seems useless, how do I do?

So you have set Node.isTreeExpanded to false in your Node template, yes? That way the only nodes that show are the root node(s).

Then all you need to do is expand those root node(s) to the level that you want. Something like this DiagramEvent listener:

          "InitialLayoutCompleted": function(e) {
            e.diagram.findTreeRoots().each(function(root) {
              root.expandTree(4);
            });
          }

Gosh, you’re awesome, thanks for your help