![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
I'm trying to access the TextInput field with id="txtPhoto" when the user
clicks the Button with id="btnBrowse" from inside the itemRenderer element. Here's what the DataGridColumn looks like. I seem to be able to find the parent element of the button from the event; but how do you then traverse down and find the HBox and then the TextInput within that? Further down, I have the code that I'm using to try to access the element. <mx ataGridColumn 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 )"/> <mx:Button id="btnUpload" label="Upload" click="outerDocument.doSubmit( event )"/> </mx:HBox> </mx:Component> </mx:itemRenderer> </mx ataGridColumn>Here's the code that needs to access the TextInput for this specific row whose btnBrowse has been clicked, // Called when the "Browse" button is clicked public function doBrowse( event:Event ):void { file.browse(); var lb:mx.controls.listClasses.ListBaseContentHolder = event.target.parent.parent; if (lb==null) return; // This code doesn't work -- says: // TypeError: Error #1010: A term is undefined and has no properties. for (var i:int = 0; i < lb.numChildren; i++){ var hb:HBox = lb.listItems[i][0] as HBox; if (hb==null) continue; var ti:TextInput = hb.getChildAt(1) as TextInput; if (ti==null) continue; ti.text = "hello world!"; break; } } |
| Sponsored Links |
|
|||
|
I'm trying to access the TextInput field with id="txtPhoto" when the user
clicks the Button with id="btnBrowse" from inside the itemRenderer element. Here's what the DataGridColumn looks like. I seem to be able to find the parent element of the button from the event; but how do you then traverse down and find the HBox and then the TextInput within that? Further down, I have the code that I'm using to try to access the element. <mx ataGridColumn 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 )"/> <mx:Button id="btnUpload" label="Upload" click="outerDocument.doSubmit( event )"/> </mx:HBox> </mx:Component> </mx:itemRenderer> </mx ataGridColumn>Here's the code that needs to access the TextInput for this specific row whose btnBrowse has been clicked, // Called when the "Browse" button is clicked public function doBrowse( event:Event ):void { file.browse(); var lb:mx.controls.listClasses.ListBaseContentHolder = event.target.parent.parent; if (lb==null) return; // This code doesn't work -- says: // TypeError: Error #1010: A term is undefined and has no properties. for (var i:int = 0; i < lb.numChildren; i++){ var hb:HBox = lb.listItems[i][0] as HBox; if (hb==null) continue; var ti:TextInput = hb.getChildAt(1) as TextInput; if (ti==null) continue; ti.text = "hello world!"; break; } } |
|
|||
|
I'm trying to access the TextInput field with id="txtPhoto" when the user
clicks the Button with id="btnBrowse" from inside the itemRenderer element. Here's what the DataGridColumn looks like. I seem to be able to find the parent element of the button from the event; but how do you then traverse down and find the HBox and then the TextInput within that? Further down, I have the code that I'm using to try to access the element. <mx ataGridColumn 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 )"/> <mx:Button id="btnUpload" label="Upload" click="outerDocument.doSubmit( event )"/> </mx:HBox> </mx:Component> </mx:itemRenderer> </mx ataGridColumn>Here's the code that needs to access the TextInput for this specific row whose btnBrowse has been clicked, // Called when the "Browse" button is clicked public function doBrowse( event:Event ):void { file.browse(); var lb:mx.controls.listClasses.ListBaseContentHolder = event.target.parent.parent; if (lb==null) return; // This code doesn't work -- says: // TypeError: Error #1010: A term is undefined and has no properties. for (var i:int = 0; i < lb.numChildren; i++){ var hb:HBox = lb.listItems[i][0] as HBox; if (hb==null) continue; var ti:TextInput = hb.getChildAt(1) as TextInput; if (ti==null) continue; ti.text = "hello world!"; break; } } |
|
|||
|
"curious_Lee" <webforumsuser@macromedia.com> wrote in message news:gbr2jd$qgn$1@forums.macromedia.com... > I'm trying to access the TextInput field with id="txtPhoto" when the user > clicks the Button with id="btnBrowse" from inside the itemRenderer > element. > Here's what the DataGridColumn looks like. I seem to be able to find the > parent > element of the button from the event; but how do you then traverse down > and > find the HBox and then the TextInput within that? Further down, I have the > code > that I'm using to try to access the element. > > <mx ataGridColumn 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 )"/> > <mx:Button id="btnUpload" label="Upload" > click="outerDocument.doSubmit( event )"/> > </mx:HBox> > </mx:Component> > </mx:itemRenderer> > </mx ataGridColumn>> > Here's the code that needs to access the TextInput for this specific row > whose > btnBrowse has been clicked, > > // Called when the "Browse" button is clicked > public function doBrowse( event:Event ):void > { > file.browse(); > var lb:mx.controls.listClasses.ListBaseContentHolder = > event.target.parent.parent; > > if (lb==null) return; > > // This code doesn't work -- says: > // TypeError: Error #1010: A term is undefined and has no properties. > for (var i:int = 0; i < lb.numChildren; i++){ > var hb:HBox = lb.listItems[i][0] as HBox; > > if (hb==null) continue; > var ti:TextInput = hb.getChildAt(1) as TextInput; > if (ti==null) continue; > ti.text = "hello world!"; > break; > } > } Why go UP to the contentHolder and then back DOWN to the HBox that is the parent of the thing that was clicked? But I reiterate that if you use an itemClick event instead of a regular click event, you will receive a different kind of event that has properties specific to working with data. HTH; Amy |
|
|||
|
"curious_Lee" <webforumsuser@macromedia.com> wrote in message news:gbr2jd$qgn$1@forums.macromedia.com... > I'm trying to access the TextInput field with id="txtPhoto" when the user > clicks the Button with id="btnBrowse" from inside the itemRenderer > element. > Here's what the DataGridColumn looks like. I seem to be able to find the > parent > element of the button from the event; but how do you then traverse down > and > find the HBox and then the TextInput within that? Further down, I have the > code > that I'm using to try to access the element. > > <mx ataGridColumn 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 )"/> > <mx:Button id="btnUpload" label="Upload" > click="outerDocument.doSubmit( event )"/> > </mx:HBox> > </mx:Component> > </mx:itemRenderer> > </mx ataGridColumn>> > Here's the code that needs to access the TextInput for this specific row > whose > btnBrowse has been clicked, > > // Called when the "Browse" button is clicked > public function doBrowse( event:Event ):void > { > file.browse(); > var lb:mx.controls.listClasses.ListBaseContentHolder = > event.target.parent.parent; > > if (lb==null) return; > > // This code doesn't work -- says: > // TypeError: Error #1010: A term is undefined and has no properties. > for (var i:int = 0; i < lb.numChildren; i++){ > var hb:HBox = lb.listItems[i][0] as HBox; > > if (hb==null) continue; > var ti:TextInput = hb.getChildAt(1) as TextInput; > if (ti==null) continue; > ti.text = "hello world!"; > break; > } > } Why go UP to the contentHolder and then back DOWN to the HBox that is the parent of the thing that was clicked? But I reiterate that if you use an itemClick event instead of a regular click event, you will receive a different kind of event that has properties specific to working with data. HTH; Amy |
|
|||
|
"curious_Lee" <webforumsuser@macromedia.com> wrote in message news:gbr2jd$qgn$1@forums.macromedia.com... > I'm trying to access the TextInput field with id="txtPhoto" when the user > clicks the Button with id="btnBrowse" from inside the itemRenderer > element. > Here's what the DataGridColumn looks like. I seem to be able to find the > parent > element of the button from the event; but how do you then traverse down > and > find the HBox and then the TextInput within that? Further down, I have the > code > that I'm using to try to access the element. > > <mx ataGridColumn 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 )"/> > <mx:Button id="btnUpload" label="Upload" > click="outerDocument.doSubmit( event )"/> > </mx:HBox> > </mx:Component> > </mx:itemRenderer> > </mx ataGridColumn>> > Here's the code that needs to access the TextInput for this specific row > whose > btnBrowse has been clicked, > > // Called when the "Browse" button is clicked > public function doBrowse( event:Event ):void > { > file.browse(); > var lb:mx.controls.listClasses.ListBaseContentHolder = > event.target.parent.parent; > > if (lb==null) return; > > // This code doesn't work -- says: > // TypeError: Error #1010: A term is undefined and has no properties. > for (var i:int = 0; i < lb.numChildren; i++){ > var hb:HBox = lb.listItems[i][0] as HBox; > > if (hb==null) continue; > var ti:TextInput = hb.getChildAt(1) as TextInput; > if (ti==null) continue; > ti.text = "hello world!"; > break; > } > } Why go UP to the contentHolder and then back DOWN to the HBox that is the parent of the thing that was clicked? But I reiterate that if you use an itemClick event instead of a regular click event, you will receive a different kind of event that has properties specific to working with data. HTH; Amy |
|
|||
|
Thanks, Amy. Now I'm able to update the TextInput; however, I've run into an
issue where, after you've set the TextInput, if you scroll the datagrid, you'll notice (randomly) other TextInput fields in the same column with the same value. After some research, it appears to be that the itemRenderers are recycled -- only the first 10 or 12 rows have itemRenderers generated for them: [bullet] http://www.adobe.com/devnet/flex/art...erers_pt1.html [/bullet] [bullet] http://blogs.adobe.com/aharui/2007/0...nderers_1.html [/bullet] What a bummer. I can't write the filename the person selected to the dataprovider (the solution to the recycling issue) unless the user clicks the Upload button. One solution: Do a popup itemRenderer, where the only choices the user has are [Upload] and [Cancel]. This way we don't run into the issue. I know it's a performance reason as to why itemRenderers are recycled; but I wish it were better documented. I almost lost my mind before I realized what was going on! Also, I wish there was a way to turn it off -- even if it means poor performance. |
|
|||
|
Thanks, Amy. Now I'm able to update the TextInput; however, I've run into an
issue where, after you've set the TextInput, if you scroll the datagrid, you'll notice (randomly) other TextInput fields in the same column with the same value. After some research, it appears to be that the itemRenderers are recycled -- only the first 10 or 12 rows have itemRenderers generated for them: [bullet] http://www.adobe.com/devnet/flex/art...erers_pt1.html [/bullet] [bullet] http://blogs.adobe.com/aharui/2007/0...nderers_1.html [/bullet] What a bummer. I can't write the filename the person selected to the dataprovider (the solution to the recycling issue) unless the user clicks the Upload button. One solution: Do a popup itemRenderer, where the only choices the user has are [Upload] and [Cancel]. This way we don't run into the issue. I know it's a performance reason as to why itemRenderers are recycled; but I wish it were better documented. I almost lost my mind before I realized what was going on! Also, I wish there was a way to turn it off -- even if it means poor performance. |
|
|||
|
Thanks, Amy. Now I'm able to update the TextInput; however, I've run into an
issue where, after you've set the TextInput, if you scroll the datagrid, you'll notice (randomly) other TextInput fields in the same column with the same value. After some research, it appears to be that the itemRenderers are recycled -- only the first 10 or 12 rows have itemRenderers generated for them: [bullet] http://www.adobe.com/devnet/flex/art...erers_pt1.html [/bullet] [bullet] http://blogs.adobe.com/aharui/2007/0...nderers_1.html [/bullet] What a bummer. I can't write the filename the person selected to the dataprovider (the solution to the recycling issue) unless the user clicks the Upload button. One solution: Do a popup itemRenderer, where the only choices the user has are [Upload] and [Cancel]. This way we don't run into the issue. I know it's a performance reason as to why itemRenderers are recycled; but I wish it were better documented. I almost lost my mind before I realized what was going on! Also, I wish there was a way to turn it off -- even if it means poor performance. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise