Trying to get a list of immediate members of a group so I can set the last node or group inside the parent to selected when parent group is expanded. However, it looks like the parts are not in any order. In my model the group has 2 sub-groups and the 2nd group is the first element of groupMembers. One more point, in our model the groups are not connected to each other or nodes only nodes inside groups are connected. How do you suggest ordering the parts so I can get the last member? Here is my code so far:
// get last member of group
const groupParts = group.memberParts;
const groupMembers = [];
groupParts.each((part) => {
if (part instanceof go.Node || part instanceof go.Group) {
groupMembers.push(part);
}
});
Directed graphs can have cycles, which is why I was asking about how you determine the “last” node.
Even if you don’t have any cycles, there might be more than one node that is “last”.
But I guess you must have figured that out already. OK, if you already know the node(s) that need to be selected, you just need to implement a Group.subGraphExpandedChanged event handler to check whether the argument has Group.isSubGraphExpanded true, and if so, to set Part.isSelected on those node(s). Group | GoJS API