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;
}

 

Reply via email to