Using data binding and conversion function with arrays

Hi,

I’ll try to explain my question through an example.
Let’s assume I have the following nodeData entry:

{
  category: "defaultNode",
  name: "abc",
  parameters: [{
    p1: "eee",
    p2: "fff"
  },
  { 
    p1: "ggg",
    p2: "hhh"
  }]
}

Now I need a binding with a conversion function to concatenate p1 of all parameters:

go.Binding("text", "parameters", (parameters: Array<any>, panel: go.Panel) => {
  let concat = "";
  for (let parameter of parameters) {
    concat += parameter.p1;
  }
  return concat;
}

This works fine on initial display.

But how can I now update the p1 attribute in the node data so that the binding is updated automatically?
I tried it like model.setDataProperty(part.data.parameters[0], "p1", "ppp"); but the binding doesn’t get called. I assume the issue is that I am modifying an object in the array and not the array itself?

Do I need to call part.updateTargetBindings(“parameters”) after updating the data or is there a better way?

Best regards,
Dominic

Yes, you understand it correctly. The Binding does not have a source == “p1”, so it is not evaluated.

And yes, if you can call updateTargetBindings afterwards, that would be best. But you can call Model.updateTargetBindings on the node data object with “parameters” as the property name.

Thank you for the confirmation!