【问题标题】:gojs apply parameter only when part of groupgojs 仅在组的一部分时应用参数
【发布时间】:2020-12-22 21:20:52
【问题描述】:

使用 gojs,我想只在对象放在另一个对象中时应用参数。

例如,当面板放置在 H 组中时,应该只添加填充 (or change value, from 0 to 25)

这可能吗? 查看gojs docs 我看到SelectionGrouped 但不确定这是否包括将对象放入H Group

myDiagram.nodeTemplateMap.add("j2",
                $(go.Node, "Auto",
                    $(go.Panel, "auto", {padding:0},
                        $(go.Shape, "File"),
                        $(go.TextBlock,  "This\n is a\n file", textStyle(),
                            new go.Binding("text", "text").makeTwoWay())
                    )
                ));

【问题讨论】:

    标签: gojs


    【解决方案1】:

    您可以在使用Group.memberAdded and memberRemoved`https://gojs.net/latest/api/symbols/Group.html#memberAdded 将部件添加到组或从组中删除时触发事件

    或者您可以在 Part(不是 Group)上进行数据绑定,以在其 containingGroup 不为空时执行不同的操作。示例绑定:

          new go.Binding("margin", "containingGroup", function(a) {
            if (a === null) return 5;
            // otherwise its in a group:
            return 15;
          }).ofObject(),
    

    在这里现场观看: https://codepen.io/simonsarris/pen/LYNOpme?editors=1010

    【讨论】:

      猜你喜欢
      • 2014-07-18
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多