Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the ItemRenderer of a Flex Spark List from its DataProvider Object?

In Flex I can create an ItemRenderer to represent each item in the Lists DataProvider but how do I access the instance of the ItemRenderer via the DataProviders Object? Something like myList.getItemRenderer(dp.getItemAt(10));

like image 894
Lee Probert Avatar asked Dec 02 '22 04:12

Lee Probert


1 Answers

public function getItemRenderer(list:List, item:Object):ItemRenderer
{
    var dataGroup:DataGroup = list.dataGroup;
    var n:int = dataGroup.numElements;
    for (var i:int = 0; i < n; i++)
    {
        var renderer:ItemRenderer = dataGroup.getElementAt(i) as ItemRenderer;
        if (renderer && renderer.data == item)
            return renderer;
    }
    return null;
}
like image 98
Maxim Kachurovskiy Avatar answered Apr 28 '23 12:04

Maxim Kachurovskiy