How to get item object from it's child object?

I’d like to get item object from it’s child object when user click child object.
For example:

itemTemplate:
$(go.Panel, "Auto",
  $(go.Shape, "Rectangle"),
  $(go.Panel, "Auto",
    {
       click: function(e, obj){
          // How to get item object from obj?
          //obj.part returns node, not item object
        }
    }
 )
)

Or how to get item index from it’s child object in the item template?
Regards

The second argument to the click event handler will be the object on which the event was defined. So in your case:

  • obj will be the nested Panel
  • obj.panel will be its container, the item panel
  • obj.panel.data will be the item value, from the Array
  • obj.panel.panel.itemArray will be that Array

There’s an undocumented method to find the container Panel whose Panel.data is the data to which the panel is bound: GraphObject.findTemplateBinder.