Grouping with Freehand drawing

I am creating a group with archetypeGroupData.
myDiagram.commandHandler.archetypeGroupData={category: “group”,LocalId:pLocalId,key:pLocalId, Text:“Group”, isGroup: true, BackColor:"#242e38",LineColor:"#7e8b8c"…

Once the group is created, now drop a free hand drawing tool on the group and validate it and add the freehand drawing to the group by finish drop event
if(grp != null && grp != undefined)
var ok = grp.addMembers(grp.diagram.selection, true);
if (!ok) grp.diagram.currentTool.doCancel();

My group template looks like this.

groupTemplate = GOJS(go.Group, go.Panel.Spot,
ungroupable: true,
// highlight when dragging into the Group
mouseDragEnter: function(e, grp, prev) { highlightGroup(e, grp, true); },
mouseDragLeave: function(e, grp, next) { highlightGroup(e, grp, false); },
computesBoundsAfterDrag: true,
// when the selection is dropped into a Group, add the selected Parts into that Group;
// if it fails, cancel the tool, rolling back any changes
mouseDrop: finishDrop,
new go.Binding(“location”, “loc”),
GOJS(go.Panel, go.Panel.Auto,
{ stretch: go.GraphObject.Horizontal, background: “#000c19” },
GOJS(go.Shape, “RoundedRectangle”,// surrounds the Placeholder
{strokeWidth: 2},
new go.Binding(“fill”, “BackColor”),new go.Binding(“stroke”, “LineColor”),new go.Binding(“key”, “LocalId”).makeTwoWay()),
GOJS(go.Panel, “Vertical”,
{ defaultAlignment: go.Spot.Left, margin: 4 },
GOJS(go.Panel, “Horizontal”,
{ defaultAlignment: go.Spot.Top },
// the SubGraphExpanderButton is a panel that functions as a button to expand or collapse the subGraph
GOJS(go.TextBlock, // group title
{ alignment: go.Spot.TopLeft, font: “400 24px Noto Sans CJK JP” , stroke: “#ebeff0”},
new go.Binding(“text”, “Text”))
// create a placeholder to represent the area where the contents of the group are
{ padding: new go.Margin(0, 4),background: “white” })
) // end Vertical Panel

Making groups and adding childs sample code:

$.each(BO.BusinessOrigami.Groups, function (i, group)
myDiagram.startTransaction(“make new group”);
myDiagram.model.addNodeData({Text:group.Text, key:group.LocalId, isGroup: true, group:group.ParentGroup, loc:new go.Point(group.GroupSymbols[i].LocationX,group.GroupSymbols[i].LocationY), BackColor:group.BackColor,LineColor:group.LineColor,Type:group.Type,category: “group”,Item:group});
myDiagram.commitTransaction(“make new group”);

if(group.LocalGroupSymbols != undefined && group.LocalGroupSymbols != null)
//update group id for each child
if(myDiagram.findNodeForKey(xy) != null)
myDiagram.findNodeForKey(xy) = group.LocalId;
var v = group.findSubGraphParts;
if(group.ParentGroup != undefined && group.ParentGroup != “”)
var grpObj = myDiagram.findNodeForKey(group.LocalId);
if(grpObj != undefined)
{ =;

After saving the freehand drawing is coming out of the group !!

What am i missing here??

There are several issues with your code. But it’s hard to tell when the code is not indented. Paste your code inside triple-backquotes in the forum’s editor.

The major one might be that you are simply modifying the property without calling GraphLinksModel.setGroupKeyForNodeData or Model.setDataProperty (which in this case would call setGroupKeyForNodeData for you).

Another thing I notice is that you are binding the Shape.key property – yet there is no such property defined, and making it a TwoWay binding seems pointless. I highly recommend using the go-debug.js library and watching the console log output for warnings and errors.

My apologies for not indented code and delay in response.

Your suggestion to set data property worked like charm.