Main

24 november 2008

How to get an instance of the parent List from an ItemRenderer

In Adobe Flex, instead of using parent.parent, it is not easy to get an instance of the parent List into your ItemRenderer. To do so you must implement the mx.controls.listClasses.IDropInListItemRenderer interface and add the functions
public function get listData():BaseListData
{
 return _listData;
}

public function set listData(value:BaseListData):void
{
 _listData = value;
 if(_listData)
 {
  var parentList:List = List(listData.owner);
 }
}

example source