in my project I’m using a binding to the itemArray to create a bunch of ports for a node. The array is not directly linked, but computed by the converter function. However, triggering the binding removes all existing links to ports inside the items.
So it’s something like:
new go.Binding("itemArray","", function(v,n){
arr = [];
//now fill it
return arr;
})
If I change it so it does not create a new array and the references stay the same, the connected links don’t vanish. However, the template for the ports is not updated as the references have not changed -.-
The ports created have the same id and stuff, so there is actually no reason for the links to disappear. I think that updating the template first removes everything and propagates that to the links before creating the new content.
new go.Binding("itemArray","", function(v, n) {
n.part.data["_tmp"] = n.part.data["_tmp"] || {}; // create temporary data on first touch
data["_tmp"].arr = data["_tmp"].arr || []; // create temporary array on first touch
var arr = data["_tmp"].arr;
// loop over given array
for (var i=0; i<GlobalArray.length; i++) {
var port = GlobalArray[i];
if (i >= arr.length) { // add new elements on first touch, this is the portId
arr.push({id:("port"+i)})
}
arr[i].name = port.name; // change some values
}
return arr;
})
It seems it is important to keep the reference unchanged. Replacing data["_tmp"].arr = data["_tmp"].arr || [];
with data["_tmp"].arr = [];
so starting with a complete new array, results in the behavior explained above.
Yes, that’s wrong. We’ll look into it as soon as we get a chance later this morning, although the eclipse will probably distract us for an hour in the afternoon. https://eclipse2017.nasa.gov/
I believe this will be fixed for 1.7.20. Setting Panel.itemArray (either directly or via binding) will call Panel.rebuildItemElements, which should now preserve any connected Links. I hope we’ll release later this week.