2016-06-30 8 views
1

内の重複リンクを制御することが可能です私の質問は、その要素のいずれかの場合には、重複するリンクを許可しないことも可能です左右に既にリンクがありますか?あなたの最初の回答に基づいては内のリンク</p> <p><a href="http://gojs.net/latest/samples/treeMapper.html" rel="nofollow noreferrer">http://gojs.net/latest/samples/treeMapper.html</a></p> <p>以下のように私はGOJS図の何かのリンクを実装していますGOJS

が、私は

myDiagram.nodeTemplate = 
       $(TreeNode, 
       { movable: false }, // user cannot move an individual node 
       // no Adornment: instead change panel background color by binding to Node.isSelected 
       { selectionAdorned: false }, 
       { fromLinkable: true, toLinkable: true,fromMaxLinks: 1,toMaxLinks:1 }, // user can draw link to and from such tree nodes 
       $("TreeExpanderButton", // support expanding/collapsing subtrees 
        { width: 14, height: 14, 
        "ButtonIcon.stroke": "black", 
        "ButtonIcon.strokeWidth": 2, 
        "ButtonBorder.fill": "whitesmoke", 
        "ButtonBorder.stroke": "black", 
        "ButtonBorder.figure": "Rectangle" 
        }), 
       $(go.Panel, "Horizontal", 
        { position: new go.Point(16, 0) }, 
        new go.Binding("background", "isSelected", function(s) { return (s ? "lightblue" : "white"); }).ofObject(), 

        $(go.TextBlock,{ font: '9pt Verdana, sans-serif' }, 
        new go.Binding("text", "Data", function(s) { return s; })) 
       ) // end Horizontal Panel 
      ); // end Node 

注意以下のようnodeTemplateのコードを更新しました:これはちょうど木の実装ではありませんに示すように、これは、レコードのマッピングフィールドの一部として実装ツリーです私が共有しているリンク。

私が望むすべては、各ポートは、サービスのparamsのコンテナ車である図中の複数のリンクenter image description here

は、デバイスモデル内の他のノードに複数のリンクを持つべきではない持っていないはずです。同様に、デバイスモデル内のデバイスは、サービスパラメータから複数のリンクを取得するべきではありません。他のすべてのノードについても同様です。

答えて

0

次のようにcheckLink述語を向上:使用して気にしないでください // whether the user can start drawing a link from or to this node depends on which group it's in new go.Binding("fromLinkable", "group", function(k) { return k === -1; }), new go.Binding("toLinkable", "group", function(k) { return k === -2; }), function checkLink(fn, fp, tn, tp, link) { // make sure the nodes are inside different Groups if (fn.containingGroup === null || fn.containingGroup.data.key !== -1) return false; if (tn.containingGroup === null || tn.containingGroup.data.key !== -2) return false; // optional limit to a single mapping link per node if (fn.linksConnected.any(function(l) { return l.category === "Mapping"; })) return false; if (tn.linksConnected.any(function(l) { return l.category === "Mapping"; })) return false; return true; }

を、代わりに盲目的にtrueにそれらを設定するfromLinkabletoLinkableの値は約賢くするノードテンプレートを変更しますfromMaxLinkstoMaxLinksのプロパティは、Tree Mapperサンプルが使用するさまざまな種類のリンクを区別しないためです。

詳しくはhttp://gojs.net/latest/intro/validation.htmlhttp://gojs.net/latest/intro/ports.htmlをご覧ください。

+0

私は思っていません。出来た。私の質問をコードと出力図で更新しましょう。私はどこで間違っているのかを確認して確認できますか? – Nadvez

関連する問題

 関連する問題