Found a solution that's posted to my blog for anyone who runs into
this issue:
http://devharbor.blogspot.com/2008/10/solution-to-flex-itemrenderer-recycling.html

--- In [email protected], jitendra jain
<[EMAIL PROTECTED]> wrote:
>
> Try itemEditEnd event  of data grid. This event is fired when the
data is edited and the user is about to lose the  focus. Now in this
event try to do whatever validation you need to do and if the data is
not valid, call event.preventDefault() 
>  Thanks,
> 
> with Regards,
> Jitendra Jain
> 
> 
> 
> 
> ----- Original Message ----
> From: Tracy Spratt <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Tuesday, 30 September, 2008 2:05:29 AM
> Subject: RE: [flexcoders] Problem referring to TextInput in itemRenderer
> 
> 
> 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] ups.com [mailto: [EMAIL PROTECTED]
ups.com ] On Behalf Of oneworld95
> Sent: Monday, September 29, 2008 4:05 PM
> To: [EMAIL PROTECTED] ups.com
> 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="outerDocumen t.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;
> } 
> 
> 
>       Add more friends to your messenger and enjoy! Go to
http://messenger.yahoo.com/invite/
>


Reply via email to