Link Template make two way does not work

Hi,

  1. I was facing two issues in this code. i made it two way but when i update High property with another colour , it is not getting updated untill i use “diagram.updateAllTargetBindings” .

this.(go.Link, { curve: go.Link.Bezier, relinkableFrom: true, relinkableTo: true, toShortLength: 3, toEndSegmentLength: 40, fromEndSegmentLength: 40 }, this.(go.Shape, // the link shape
{ stroke: “gray” },
new go.Binding(“stroke”, “High”).makeTwoWay()
),
this.$(go.Shape, { toArrow: “Standard” }, new go.Binding(“fill”, “High”).makeTwoWay())
);
eg: modellinkArray i am using { from: srcTableName, to: tgtTableName, fromPort: srcColName, toPort: tgtColName,High:“red”}

  1. i want to validate the property in two way i am unable to make it.
    eg:
    “”"
    modellinkArray i am using { from: srcTableName, to: tgtTableName, fromPort: srcColName, toPort: tgtColName,High:true}

this.$(go.Shape,
{ stroke: “gray” },
new go.Binding(“stroke”, “High”).makeTwoWay((n)=> {return “red”};) // i want to validate here
),

“”"
Please make it done.Thanks.

Please format your code so that it is legible, as I did in your previous post.

  1. How did you update the data? Did you call Model.set (a.k.a. Model.setDataProperty)? Did you make all of the changes within one whole transaction? Please read:
    GraphObject Manipulation (the last sections)
    GoJS Transactions -- Northwoods Software

  2. If you have a TwoWay Binding, it must be the case that some code is modifying the GraphObject property that is the target of the binding. What’s even more implausible is that you have two bindings that use “High” as the source property. What code of yours is modifying either the one shape’s Shape.stroke property or the other shape’s Shape.fill property?

If such code does exist, then it makes sense that there be a TwoWay Binding on the property. BUT – it should be the responsibility of that code to do its own validation. It is not the responsibility of the binding mechanism to check for semantic errors.

And my guess is that no such code exists, so you should not be using TwoWay Bindings at all there.

The whole concept of validation should be to prevent users from making mistakes, not to try to fix it up after the wrong change has already been made.

Thanks Walter,
sorry for the late replay.

  1. I am updating data using link.data.High = “blue” or by link.High=“blue” without any transaction.
  2. i want to change two properties stroke and fill for two different shapes. when i change the two way bined data. is it possible ??

Did you read the links I just gave you? Or maybe you haven’t read:
https://gojs.net/latest/intro/usingModels.html#ModifyingModels

Thanks Walter. This link is clear for me.