Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Using data binding and conversion function with arrays

$
0
0

@Dominic.Lerbs wrote:

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

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles