Binding to parent value

My model is like :

const nodeDataArray = [
  { 
    key: 'node1',
    ports: [
      in: [
        { portId: 'i1', text: 'input 1' },
        { portId: 'i2', text: 'input 2' },
      ],
      out: []
  }
]

I use multiple itemArray (ports.in, ports.out, etc.) to create ports with a basic itemTemplate.

In this itemTemplate a binding refer to the json node corresponding to the current item.

But how to create a binding to get a property from his node parent like the key (or a default value for each ports).

Ok I have find :

part.data

A default value for each port you should just set on the port in the item template.

There is not a natural way to refer to node data properties from item templates. But you can still access the node data object by using a converter function that takes a second argument. The second argument for source-to-target conversions will be the bound GraphObject. So you can get to the node data via obj.part.data.

However please note that if the property on the node data object changes, your binding in the item template will not be re-evaluated, because GoJS does not know about your dependency that you implemented in your converter function code.

EDIT: we posted at the same time. Sorry for the delay, but we’re in the US on the east coast.

Ok thanks for this precision Walter.

What can be done to trigger the re-evaluation if the parent data is changed?

Could you outline the data structures, bindings, and changes that you want to handle?

I have an attribute showing on a group alongside the name of the group. I am putting the attribute’s value in a link label between the items showing in the group. When I change the attribute on the group I would like the link label to pick up the new value.

In general Bindings work between a Part and its data, or a Part and itself (or a piece of itself). They don’t really work between two independent Parts, such as a Link and a Group in your case.

Note that the situation that you describe is not the same as this forum topic.

For your case I suggest that whenever you change the group you write the code to examine all links that are connected with the group and update those properties that seem appropriate.

Excellent, thanks. I’ve done that and achieved what I was trying to do. Thanks for your hints.