This “works”, in that it shows the node on the canvas when it loads. However, when I drag a new node over from the palette, I can’t connect them together. Is it because the node placed via code isn’t instantiated or something? Thanks!
Yep, that did the trick! Yes, all of my keys are unique.
Walter, I don’t what they are paying you there, but I will say this: The attention that I’ve received as a prospect evaluating the product has been nothing short of phenomenal. That’s hard to find these days.
One interesting side effect I’ve discovered. When I drag a new node over to the canvas and try to connect it with the one that was placed via code, my port mouseover shows me that the ports are active, and I make the connection, but as soon as I do, the link itself gets drawn to the center of the side of the node rather than the port itself. Also, if I move that node around the other node, the link auto moves to the other sides. Cool feature, but … any idea what is causing it and how do I prevent it?
Do you have multiple ports? If so, the link that you create isn’t connecting to a specific port, so it connects with the default port, named “” (the empty string), or with the whole Node if no such object has portId == “”.
Yes, I have multiple ports on each node (4 on each side). and they all have unique names. I will read up on what you posted - thanks! I’m assuming that since it works fine with elements dragged in from the palette, that your response should be targeted at the node I am placing via code … ?
Hmm. I call the addNodeData well after all of my templates have been created. From the docs on addNodeData:
This will cause a Node or simple Part to be created (copying the template found in Diagram.nodeTemplateMap), added to the Diagram in some Layer (based on Part.layerName), and bound to the node data (resulting in Panel.data referring to that node data object). Does it not copy the port data over as well?
Also, I should add that in looking at my JSON model saved to the database, it uses the defaults of topid and frompid. I’ve tried setting them manually, as follows, but no love :(
You were asking about making sure that the Arrays of port descriptors in your node data would be copied, and not shared between nodes, right? If so, then you either need to set those two properties on Model, or you need to provide a custom copying function so that you can control exactly what is copied and what is shared.
But you need to do that on the GraphLinksModel that you are displaying. Are you setting those two properties on the Diagram.model and then discarding that Model by replacing it with a new one?
That DOM element is a hidden textarea that gets populated from the model JSON stored in the database. So, is my syntax above incorrect? (i.e. myDiagram.model.copiesArrayObjects, etc).
I don’t think I need a custom function, but again, I’m still learning the parlance of GoJS, so I could be wrong. What I am trying to do sounds simple enough (to me at least). I have defined a bunch of templates, and have a palette tied into it all, and I want to populate the canvas with one of them when the page loads. And of course, I want the nodes to work as they do when I don’t autopopulate the canvas with a node, and the user just drags the elements over themselves. Hope that makes sense.