DataGrid.selectedItem is set based on user interaction at runtime, so you
can't really set it the way you are trying. You could setup a binding there
in your code using BndUtils, but ugghh, ugly. I suggest you create a new
custom component component based on Canvas that has your DataGrid and
TextArea in it. I'd use MXML for this, its more descriptive eh? In this
component you could have
<TextArea text="{ myDG.selectedItem.someProperty}" ....
The skinny is that you don't try and 'call from the DG based on ID'. Either
use bindings as above in a custom component or use the event system.
HTH!
DK
On Mon, Sep 8, 2008 at 11:37 AM, Lucas Golden <[EMAIL PROTECTED]> wrote:
> I've created a Datagrid and Accordion dynamically based on my XML (It
> creates a Accordion tab per "header" node and then inside of the Datagrid it
> puts a DG item for each "Question" node inside of the respective "Header"
> node). Now, I'm wanting to bring up text in to a TextBox based on the
> selected item of the created Datagrid. Now, I know you would normally do
> this via the text attribute of the TextArea being set to something like
> "text = {DatagridID.selectedItem.displayText}". However, it seems I'm
> having problems identifying the ID of the Datagrid I'm trying to call from.
> I've tried setting the Datagrid ID, but since it's not defined at compile
> time, it cannot see it as a valid ID to read from if I try to just use it.
>
> The following is the code of the Accordion creation function and I'll mark
> where I need the text to be written out. Thanks again!
>
> -------CODE-------
>
> public function buildAccordian(contentArray:ArrayCollection):void
> {
> var accordian:Accordion = new Accordion();
>
>
>
>
> for (var i:int = 0; i < int(contentArray.length); i++)
> {
>
> if(contentArray[i].blnIsHeader == 1)
> {
> var newCanvas:Canvas = new Canvas();
> newCanvas.label = contentArray[i].label;
> newCanvas.id = "Tab" + contentArray[i].oID;
> newCanvas.width = 600;
> newCanvas.height = 400;
>
>
> DGArray = contentArray[i].Question;
>
>
>
> var newDG:DataGrid = new DataGrid();
> var newDGCol:DataGridColumn = new
> DataGridColumn("Questions");
> newDGCol.dataField = "label";
> newDGCol.wordWrap = true;
> var cols:Array = newDG.columns;
> cols.push(newDGCol);
> newDG.variableRowHeight = true;
> newDG.selectedIndex = 0;
> newDG.columns = cols;
> newDG.width = 200;
> newDG.height = 350;
> newDG.x = 15;
> newDG.y = 15;
> newDG.id = "QDG" + i;
> newDG.dataProvider = DGArray;
>
> newCanvas.addChild(newDG);
>
> var newTextArea:TextArea = new TextArea();
>
> newTextArea.width = 350;
> newTextArea.height = 330;
> newTextArea.x = 230;
> newTextArea.y = 35;
>
> if(DGArray != null)
> {
>
> *THIS IS WHERE I NEED TO BE ABLE TO
> SET THE TEXT BOX TEXT*
> newTextArea.htmlText =
> newDG.selectedItem.answer; *<---THIS DOES NOT WORK.*
>
> }
>
> newCanvas.addChild(newTextArea);
>
> var newLabel:Label = new Label();
> newLabel.text = "Answer";
> newLabel.x = 230;
> newLabel.y = 15;
> newCanvas.addChild(newLabel);
>
>
> }
>
> accordian.addChild(newCanvas);
>
> }
>
>
> pageCanvas.addChild(accordian);
> }
>
>
>
> Thanks again everyone!
>
> Luke Golden
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in
> the subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by FusionLink <http://www.fusionlink.com>
> -------------------------------------------------------------
--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?
-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the
subject line
For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------