0
votes

I've a Tree with checkbox with dataprovider as an xmlList. Now I need to get the item renderer of the list item without click on item and by search the from outside.

protected function btnSearch_clickHandler():void
        {   
             var searchString:String = txtInputSearch.text;
                if(searchString != "")
                {
                    StyleItemsArray.removeAll();
                    var conaintList:XMLList = (treeSource.node.(@label.search(searchString) > -1) as XMLList);

                    for each(var xmlItem:XML in conaintList)
                    {   
                        // trigger the checkbox click event here
                    }
                }
        }

Sorry for delayed: I tried the solution given but it seems datagroup is used in Flex 4 but I'm still in flex 3 version. I tried couple of other way (e.g. itemToItemRenderer())but no luck. Could someone please help me out?

1
Keep in mind that there might not be an itemRenderer for each list item. You're likely better off triggering an equivalent event from the button handler, and then using data binding to update the itemRenderers in the list. - Michael Brewer-Davis
If this is a MX component (I've lost track of if they've filled out the component set for Spark), you should be able to do itemToItemRenderer. However, you might want to consider instead having the button click fire an event on the XML node instead, and then you can act as if there were a click without having a reference that (strictly speaking) you shouldn't be poking your nose into. - Amy Blankenship

1 Answers

0
votes

you can retrieve all item-render of list by just using for getElementAt.

for(var i:int=0; i < youListVariable.dataProvider.length; i++)
{
    var render:CustomFieldRenderer = youListVariable.dataGroup.getElementAt(i) as CustomFieldRenderer
    //put Your comparison condition and if condition matched then break
}

CustomFieldRenderer is your itemRender.
youListVariable is your list's id i.e. list's variable.