I have not used that method and can't sugggest why it might not be working.
I won't say what you are doing is wrong, but it is very rare that itemRenderers should be manipulated directly. What you are doing will die if someone closes a branch. I really suggest that you re-examine your approach. The "normal" way to do what your are attempting would be to have a "selected" attribute on your nodes, and have the renderer use that to set its selected state. To set all the checkboxes to selected, loop over your data as you are doing, set the selected attribute as you wish. The tree will automatically display the results. One nice thing about XML is that you can add attributes on the fly. So even if your source xml does not have a @selected attribute, you loop can add one. I do that in this example, which is for a DataGrid: http://www.cflex.net/showFileDetails.cfm?ObjectID=559 Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of paulbohnenkamp Sent: Tuesday, September 09, 2008 12:12 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: tree component and null itemRenderer If I open all the nodes in the tree, i.e. make them visible though and then try to get a handle to one of the custom item renderers I'm getting that it is null, i.e. itemRenderer in code below is always null. for each (var model:String in _carModels) { for each (var item:XML in dp..node) { if ([EMAIL PROTECTED] == model) { trace("model="+model); trace("[EMAIL PROTECTED]"[EMAIL PROTECTED]); var itemRenderer:CheckTreeRenderer = tree.itemToItemRenderer (item) as CheckTreeRenderer; trace("itemRenderer="+itemRenderer); itemRenderer.select(); } } } --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > It sounds like you may not understand that item renderers are recycled, > and do not even exist when non-visible. > > > > What exactly do you mean by "initialize" the item renderer? They are > components, and live the normal component lifecycle, including > initialize and creationComplete events. "initialization" that is not > dependent on the item node data can be done in handlers for those > events. > > > > Any properties or behaviors that are dependent on the item node data > must be manipulated through the set data, commitProperties, > updateDisplayList and invalidation mechanisms. > > > > My bet is a "customer" checkbox IS dependent on the underlying data. It > must get its value from the data and user interaction must be persisted > in the data. > > > > If you already know all this sorry, I may be misunderstanding your > question, otherwise I suggest that you find an existing item renderer to > use as an example. There will be many available. Google Alex Harui > itemRenderer. > > > > Tracy > > > > ________________________________ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of paulbohnenkamp > Sent: Tuesday, September 09, 2008 12:31 AM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] tree component and null itemRenderer > > > > I've got a tree component with an customer checkbox itemRenderer and on > init of the outer component I need all the itemRenderers to be > initialized so I can call a method on the itemRenderer to select them > based on the result of a web service call. Is there a way to do this? > Somehow loop through the items in the tree dataprovider and select them > all so the itemRenderers are all initialized? > > I tried tree.openItems and looping through and doing tree.expandItem > (item, true) but that doesn't seem to init the itemRenderers. >