Can I change property in link template after set?


Can I change the properties of routing and curve after the link template of the diagram was set? If yes, how can I ask the diagram to render again using the new setting in the link template?


You cannot modify anything in a template once the template has been used to make copies of Parts (or just Panels, if item templates). This allows templates to be shared.

But you can modify the copied Parts that are in your Diagram as much as you want. The Diagram will automatically update if you are performing a transaction. Are you looking to modify lots of Links all at once? I think you are going to have to iterate over Diagram.links searching for those with a particular Link.category, if you need to identify which template it was copied from.

I tried to do something similar to this (or maybe identically) and it didn’t work at all. I used the following code to update my links:
var itr = workItemDiagram.links;
while ( {
itr.routing = go.Link.Orthogonal;
However, the diagram never updates. I can’t find any examples regarding dynamically updating the link routing. Is there a way to actually do this?
I tried wrapping it in a transaction - didn’t work. I tried calling layoutDiagram(true) and it just re-drew the original diagram using the original routing.

Any ideas?

I think you mean:

while ( { itr.value.routing = ...; }

Walter, this worked perfect except for one issue. When I try to change the segmentIndex or segmentFraction, neither one has any effect on the label position (I used the format above - itr.value.segmentIndex and nothing I do seems to work. It always shows up at the mid-point in the middle segment.

Any ideas here?

Do you surround all of the changes with calls to startTransaction and commitTransaction?

“itr.value” in that code is a Link. It doesn’t make sense to set Link.segmentIndex or any other properties that really should be set on the label objects, not on the Link.

Yes, it’s all surrounded in a transaction. So, that makes sense. I guess then I have to do a findObject on the link, find the textbox and then set the properties on it? Or maybe do a binding on it and set the link data with a segment fraction and bind to it? I’ll give that a try! Thanks Walter.