Search code examples
gojs

How to create binding for category in GoJS?


I am trying to bind node/link category property to a custom property in GoJS. Something like the following -

      $(go.Node, "Auto",
                new go.Binding("category", "cat").makeTwoWay(),
                ...
       );

But I have not found any example for that.

Thanks in advance


Solution

  • There is no need to have a Binding of Node.category, because Diagrams and Models already cooperate to support your setting the category property on the node data object in the model.

    If you want to use a different property name, you can set http://gojs.net/latest/api/symbols/Model.html#nodeCategoryProperty to whatever name you prefer. That appears to be "cat" in your case.