Getting object from a Item Array



I have a Node Template :
myDiagram.nodeTemplateMap.add(“decisionTree”,
$(go.Node, “Table”,
{ locationObjectName: “BODY”,
locationSpot: go.Spot.Center,
selectionObjectName: “BODY”,
selectionAdornmentTemplate:
$(go.Adornment, “Auto”,
$(go.Shape, “Rectangle”,
{ stroke: “dodgerblue”,
strokeWidth: 3,
fill: null }),
$(go.Placeholder)
),
},
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),

// the body
$(go.Panel, “Auto”,
{ row: 1, column: 1, name: “BODY”,
stretch: go.GraphObject.Fill },
$(go.Shape, “Rectangle”,
{ fill: “#BFBFBF”,
minSize: new go.Size(56, 56) }),
$(go.TextBlock,
{ margin: 10, textAlign: “center” },
new go.Binding(“text”, “key”))
), // end Auto Panel body

// the Panel holding the left port elements, which are themselves Panels,

$(go.Panel, “Vertical”,
{ row:1, column:2,
itemTemplate:
$(go.Panel,“Vertical”,
$(“Button”, // button A
{ name:“Button”,
click: function (e, obj) { buttonExpandCollapse(obj, “ButtonA”); }

},
/new go.Binding(“name”, “name”),/
new go.Binding(“portId”, “portId”),
$(go.TextBlock,
new go.Binding(“text”, “text”))
) // end button A

) // end itemTemplate
},
new go.Binding(“itemArray”, “itemArray”)
) // end Horizontal Panel

)); // end Node

As shown in image i have a accordian “properties” where option Lists all the names of buttons(eg: Node0 , Node1)

and Text is just an html text box using which u can change the name.

Node Data along with item array is :
var nodeDataArray = [
{category: “decisionTree”, “key”:“unit One”, “itemArray”:[ {“portId”:“start0”, “text”:“Node0”,name:“Node0”},{“portId”:“start1”, “text”:“Node1”,name:“Node1”} ] }];

using portId or name how can i get the button object from itemArray, so that on click of update properties if node0 is selected the text of node0 Button should be updated to “Node0NewText”

If you are using data binding, just call Model.setDataProperty to modify the Javascript object that is being represented by a button and whose name or other property that you want to change.

The objects in the itemArray are in order, indexed starting at 0.