Link loose port binding when bound port id is changed



when I use the following code to update the key and text

    var node1 = diagram.findNodeForKey(1);
    node1Data.itemArray[0].key = "ABC";
    node1Data.itemArray[0].text = "ABC";
    diagram.model.setDataProperty(node1Data, "itemArray", node1Data.itemArray);

then the key is updated. The text in data model is also updated, but the bound textbox shows still the old text.

When I add the command


then the text ist updated, but the link looses its port/panel/portId.

Is there a way to use model functions to update data. Or do I need to recreate the links by my own?



What’s node1Data? What’s the whole node data object in the model?


Hi Walter,

it´s the data object for node1:

You can see this in the codepen link in first post.



When I manually update the portId of all links, i.e.

diagram.links.first().toPortId = "ABC";

then the link points to the correct panel again.

From documentation: “… and that automatically updates any bindings. This override handles link data as well as node data.

When I use provided methods (i.e. setDataProperty) to update the data, then I would expect that all related diagram elements are updated too (in this case the toPortId of the Link).

(I also would expect that the diagram is notified about the change and automatically updates the view after the commit (but this is not specified in the documentation).)


The model data holds the “truth” for what exists in any diagram showing that model.

If you change a port identifier, then all links with references using the old identifier are not supposed to be connecting with that port, and all links referring to the new identifier are suddenly connecting with it.

If you want to maintain the original graph structure, you need to update all of the references. But I hope you can see how in other situations one might want the flexibility to achieve different results than what I think you want in this case.