Porting Link connection from ports to nodes

My application connects links via ports, namely, link.data has { to, from, toPort,fromPort }.
The toPort and fromPort are port keys in the to/from nodes respectively.

I was asked to connect the link directly to the node but still maintain the port list in each node.

  1. for each link i deleted the toPort/fromPort attributes, (setDataPorporety to null).
  2. Deleted the fromLinkable, toLinkable in the node template
  3. Set the diagram.model. linkFromPortIdProretpy and linkToPortIdProretpy to “” ;

What else needs to be done ?

So you just want to use the whole node as the port? You probably want to set the portId to the empty string on the main shape of the node, wherever you want the links to connect.

What do you mean by maintaining the port list in each node? Do you need to keep that information if you aren’t going to be using it?

Regarding the changes you’ve made:

  1. If you are creating your own linkDataArray, you can just leave the information out rather than using setDataProperty later.
  2. You can keep fromLinkable and toLinkable on the node object that acts as the port.
  3. Again, you don’t need to set this if it never gets initialized, since the default is the empty string.

No, I don’t want to use the node as the whole port, since the node has many ports.
Since i have a JSON string with the model that is stored in some database with the
{ to, toPort, from, fromPort } link data attributes, i would like to migrate the link to { to,from} connectivity
and still maintain the port array in the node, regardless the link connection

I’m not sure I understand what you’re trying to achieve. Do you have a screenshot of what you want?

Take a look the the following example :
nodeDataArray[] = [ {key:1, ports[] = [ { portId: ‘2-0/XE0’} ] }, {key: 2, ports[] = [ { portId: ‘0-0/XE0’} ] }, ];
linkDataArray[] = [ { from: 1, fromPort: ‘2-0/XE0’ , to: 2, toPort: ‘0-0/XE0’ } ];

I would like to migrate the data model to

nodeDataArray[] = [ {key:1, ports[] = [ { portId: ‘2-0/XE0’} ] }, {key: 2, ports[] = [ { portId: ‘0-0/XE0’} ] }, ];
linkDataArray[] = [ { from: 1, to: 2 }]

So that the link will be connected directly to the node, and still maintain the port array in node data.

If there is only ever one port per node, you can set the portId on the port object in your template to the empty string. If there can be more than one port per node, you won’t be able to do what you are asking since there will be no way for the link to determine its fromPort and toPort.

You can certainly have a variable collection of items represented by Panels in your Node, as shown in GoJS Item Arrays-- Northwoods Software, without those Panels being ports – i.e. without binding GraphObject.portId to any string.

What i did, is i removed the itemTemplate and the Binding to “itemArray” to “ports” and i don’t see the ports anymore on the node, only link.
My ports array is maintained in node.data.
I’m not sure it is sufficient.

If you just remove the link data properties fromPort and toPort, you’ll get the behavior that I think you are asking for. It might also help to not set GraphLinksModel | GoJS API and GraphLinksModel | GoJS API – i.e. leave them at their default value which is the empty string.

Then, as described at GoJS Ports in Nodes-- Northwoods Software, all links will connect with the default port of each node, which by default means the whole node. It could refer to a particular element within the node if you have set that element’s portId to "", the empty string (the default port name).

You can still have a variable list of elements corresponding to the Array items of your node data, but if you have not set or bound their portId, they will not act as ports.

Will try