@mohanr.k wrote:
Want to know if it is possible to re add the ports to node at later stage. If so could you please provide the sample code
Lets say I have below code which adds ports during node creation and at later stage my ports are getting overridden by some action so I want to re add the original ports back to node.
goObj(go.Node, "Spot",
{
locationObjectName: "SHAPE", locationSpot: go.Spot.Center,
resizable: true, resizeObjectName: "PANEL",
selectionAdorned: false // use a Binding on the Shape.stroke to show selection
},
new go.Binding("itemArray", "boundaryEventArray"),
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
// move a selected part into the Foreground layer, so it isn"t obscured by any non-selected parts
new go.Binding("layerName", "isSelected", function(s:any) { return s ? "Foreground" : ""; }).ofObject(),
goObj(go.Panel, "Auto",
{
name: "PANEL",
minSize: new go.Size(_this.ActivityNodeWidth, _this.ActivityNodeHeight),
desiredSize: new go.Size(_this.ActivityNodeWidth, _this.ActivityNodeHeight)
},
), // end Auto Panel
_this.makePort("T", go.Spot.Top, true, true),
_this.makePort("L", go.Spot.Left, false, true),
_this.makePort("R", go.Spot.Right, true, false),
_this.makePort("B", go.Spot.Bottom, true, true)
); // end go.Node, which is a Spot Panel with bound itemArraymakePort(name:any, spot:any, output:any, input:any) {
// the port is basically just a small circle
return goObj(go.Shape, "Circle",
{
fill: null,
stroke: null,
desiredSize: new go.Size(8, 8),
alignment: spot, alignmentFocus: spot, // align the port on the main Shape
portId: name, // declare this object to be a "port"
fromSpot: spot, toSpot: spot, // declare where links may connect at this port
fromLinkable: output, toLinkable: input, // declare whether the user may draw links to/from here
cursor: "pointer" // show a different cursor to indicate potential link point
}
);
}
Posts: 2
Participants: 2