我该怎么找到面板的最大宽度


我想找到宽度最长的那个面板,并把所有的面板长度设置为最长面板的长度,现在我的面板类型是auto,我应该怎么做?

That sounds like it should be done by a custom layout. Maybe something like this:

  function SameWidthTreeLayout() {
    go.TreeLayout.call(this);
  }
  go.Diagram.inherit(SameWidthTreeLayout, go.TreeLayout);

  SameWidthTreeLayout.prototype.makeNetwork = function(coll) {
    var net = go.TreeLayout.prototype.makeNetwork.call(this, coll);
    var w = 0;
    net.vertexes.each(function(v) { w = Math.max(w, v.width); });
    net.vertexes.each(function(v) { v.node.width = w; v.width = w; v.focusX = w / 2; });
    return net;
  }

This assumes that you want to set the width of the whole Node.

很对不起,你能详细的说一下该怎么用吗?我尝试了好几次,实在是不能够使它正常工作

Replace your instance of TreeLayout with an instance of this custom layout.