Hi All,
I am attempting something that I don’t know if I can or should do. I want to bind custom properties in the link to those of the port and persist that data in the LinkDataArray for use elsewhere. The additional port properties are bound twoway() so edits to them would ideally update the link data as well.
Ideally my link data which should derive from the port data would look like:
{"from":"unit Four", "to":"unit Three", "fromPort":"right0", "toPort":"left0",
//that's the stock approach that is in all examples. I need to extend that to include the following data derived from the additional port properties
"fromPortName":"Fred", "fromPortConn":"Wilma", "toPortName":"Barny", "toPortConn":"Betty"}
I am creating additional port properties:
function addPort(side) {
myDiagram.startTransaction("addPort");
myDiagram.selection.each(function(node) {
// skip any selected Links
if (!(node instanceof go.Node)) return;
// compute the next available index number for the side
var i = 0;
while (node.findPort(side + i.toString()) !== node) i++;
// now this new port name is unique within the whole Node because of the side prefix
var name = side + i.toString();
// get the Array of port data to be modified
var arr = node.data[side + "Array"];
if (arr) {
// create a new port data object
var newportdata = {
portId: name,
portColor: go.Brush.randomColor(),
portName: "Name" + i.toString(),
portConn: "Conn" + i.toString()
//I don't understand or can't find reference to the method or concept below
// if you add port data properties here, you should copy them in copyPortData above
};
// and add it to the Array of port data
myDiagram.model.insertArrayItem(arr, -1, newportdata);
}
});
myDiagram.commitTransaction("addPort");
}
I have the archtypeLinkData as:
myDiagram.toolManager.linkingTool.archetypeLinkData = {
fromPortName: 'SomePortName',
fromPortConn: 'SomePortConn',
toPortName: 'SomePortName',
toPortConn: 'SomePortConn'};
Any guidance or direction you can point me in would be appreciated.
Thanks!