{"id":2555,"date":"2018-02-01T16:17:47","date_gmt":"2018-02-01T15:17:47","guid":{"rendered":"http:\/\/www.capri-soft.de\/blog\/?p=2555"},"modified":"2018-02-01T16:17:47","modified_gmt":"2018-02-01T15:17:47","slug":"gojs-conditional-binding-bind-to-another-attribute-when-binding-not-exists","status":"publish","type":"post","link":"https:\/\/www.capri-soft.de\/blog\/?p=2555","title":{"rendered":"GoJS: Conditional Binding \/ Bind to another attribute when binding not exists"},"content":{"rendered":"<h1>Problem<\/h1>\n<p>When an attribute is not appearing in the diagram model (nodeArray), a different property should be selected<\/p>\n<h1>Ansatz &#8211; Approach<\/h1>\n<p>The third paramater of the Binding Constructor can be used to declare a function that handles the nodeData.<\/p>\n<h1>L\u00f6sung &#8211; Solution <\/h1>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ the node template describes how each Node should be constructed\r\n      diagram.nodeTemplate =\r\n        $(go.Node, &quot;Auto&quot;,  \/\/ the Shape automatically fits around the TextBlock\r\n          new go.Binding(&quot;location&quot;, &quot;loc&quot;, go.Point.parse),\r\n          $(go.Shape, &quot;RoundedRectangle&quot;,  \/\/ use this kind of figure for the Shape\r\n            \/\/ bind Shape.fill to Node.data.color\r\n            new go.Binding(&quot;fill&quot;, &quot;color&quot;)),\r\n          $(go.TextBlock,\r\n            { margin: 5, width: 100 },  \/\/ some room around the text\r\n            \/\/ bind TextBlock.text to Node.data.key\r\n\r\n            new go.Binding(&quot;text&quot;, &quot;&quot;, \r\n              function(data) \r\n              { \r\n                return (data.text) ? data.text : data.key; \r\n              }\r\n           ))\r\n          );\r\n<\/pre>\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.capri-soft.de%2Fblog%2F%3Fp%3D2555&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px;margin-top:5px;\"><\/iframe>","protected":false},"excerpt":{"rendered":"<p>Problem When an attribute is not appearing in the diagram model (nodeArray), a different property should be selected Ansatz &#8211; Approach The third paramater of the Binding Constructor can be used to declare a function that handles the nodeData. L\u00f6sung &#8211; Solution \/\/ the node template describes how each Node should be constructed diagram.nodeTemplate = &hellip; <a href=\"https:\/\/www.capri-soft.de\/blog\/?p=2555\" class=\"more-link\"><span class=\"screen-reader-text\">GoJS: Conditional Binding \/ Bind to another attribute when binding not exists<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[42,14],"tags":[],"class_list":["post-2555","post","type-post","status-publish","format-standard","hentry","category-gojs","category-htmlcss"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4yGeN-Fd","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2555"}],"version-history":[{"count":1,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2555\/revisions"}],"predecessor-version":[{"id":2556,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2555\/revisions\/2556"}],"wp:attachment":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}