Hi, Tracy. I was hoping there'd be an answer! Here's the thing: The user
first does a Browse to choose a file, then clicks the Upload button.
Then, if the upload was successful, we refresh the datagrid. What if the
user doesn't click Upload on that item, but instead scrolls the grid?
I've found articles talking about issues with the recycling,
* http://www.adobe.com/devnet/flex/articles/itemrenderers_pt1.html
*
http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.ht\
ml
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;
> }
>