Getting port name

Hi,

I’m working with DataFlow sample. I have a JSON file like in the image which contains input and output port names.
image

When makePort function returns panel as port, I can inspect it in the console like below.
image

I wonder where do you keep port name in this panel variable. Or how can I access a specific port name?
When I edit portName by editable:true property, I need to access that edited new name. Is that doable?

Thanks.

Given a reference to an existing Node, you can call Node.findPort with the portId. In the Data Flow sample, that would get you the Shape created in the makePort function. You can then navigate the visual tree to get the TextBlock.

var port = someNode.findPort("XX");
var text = port.panel.elt(port.alignment.equals(go.Spot.TopLeft) ? 1 : 0)).text;

But it would be easier and more reliable if you set the TextBlock.name property in the makePort function. If you set it to “TB”,

var port = someNode.findPort("XX");
var text = port.panel.findObject("TB").text;

Note the distinction between GraphObject.portId and GraphObject.name.

But if you want to get the new text only when the user has edited it, you can either set:
https://gojs.net/latest/api/symbols/TextBlock.html#textEdited
or define a “TextEdited” DiagramEvent:
https://gojs.net/latest/intro/events.html#TextEdited