Setting the layerName or ZOrder of all the nodes and links inside a group

Hi,

I have a scenario, when a user click on a group in gojs, it should come in the Foreground layer and all it memebers as well like nodes an links and all the other groups must go to background.
I am able to bring the group to Foreground by calling selectionChanged method. But what is the best way to bring the group’s memebers to the foreground as well with different zOrder?

If you do not specify the Part.zOrder of the Group nor of any of its member Parts, then if they are in the same layer the default z-ordering scheme is to have the Group be behind all of its members.

So if you are putting a Group in the “Foreground” Layer, you also want to put all of its members in the “Foreground” Layer. Maybe something like:

$(go.Group, . . .,
  {
    selectionChanged: function(g) {
      var newlay = g.isSelected ? "Foreground" : "";
      g.layerName = newlay;
      g.findSubGraphParts().each(function(m) { m.layerName = newlay; });
    }
  },
  . . .

Thanks @walter. It worked :)