[I tried using the Rich-Text Editor but somehow my reply didn't end up here. So a second attempt...]
I've read up on the itemRenderers recycling issue here, - http://www.adobe.com/devnet/flex/articles/itemrenderers_pt1.html - http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html The problem is compounded by this: The user does a Browse for a file, then clicks the Upload button. If the upload was successful, we write to the dataprovider. What if I pull the file browse/upload component out of the datagrid and put it by itself? So when a user clicks a row, we update that one set of controls outside of the datagrid. Is this a good way of doing it? Thanks. --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > Ah, yes. > > > > Item renderers are "recycled". Only the ones actually visible even > exist. If you have any state in an item renderer that is row / item > specific, you must ensure that that state is set from a value in the > dataProvider item, in the set data() override. Further, if a user > interacts with the renderer and changes the visual state, like entering > a text value in a TextInput, you must update the dataProvider item with > that value. > > > > I would advise doing a bit of reading on itemRenderers before going much > further. > > > > Tracy > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of oneworld95 > Sent: Monday, September 29, 2008 4:05 PM > To: [email protected] > Subject: [flexcoders] Problem referring to TextInput in itemRenderer > > > > Hi. I'm trying to refer to the TextInput control of a specific row > when the user clicks a button in that row's itemRenderer. I can change > the text in that row's TextInput, but then when I scroll I noticed > that other rows (at random) have their TextInput control set to the > same value. If I scroll up all the way, the item I had edit no longer > has its new value! I also tried reading the value from the "event" > parameter but had same result. > > Here's the MXML followed by the click handler, > > <mx:DataGridColumn id="myCol" headerText="Test" width="250"> > <mx:itemRenderer> > <mx:Component> > <mx:HBox horizontalGap="2"> > <mx:TextInput id="txtPhoto" /> > <mx:Script> > <![CDATA[ > import mx.controls.listClasses.ListBase; > ]]> > </mx:Script> > <mx:Button id="btnBrowse" label="Browse" click=" > outerDocument.doBrowse( event, this )"/> > <mx:Button id="btnUpload" label="Upload" > click="outerDocument.doSubmit( event )"/> > </mx:HBox> > </mx:Component> > </mx:itemRenderer> > </mx:DataGridColumn> > > // Called when the "Browse" button is clicked > public function doBrowse( event:Event, hbox:HBox ):void > { > var text:TextInput = hbox.getChildAt(0) as TextInput; > text.text = "testing"; > return; > } >

