Hey thanks for the help! I got it working, but now I'm having a bit of
another problem.
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
On Fri, Sep 5, 2008 at 4:49 PM, Douglas Knudsen <[EMAIL PROTECTED]>wrote:
> the loop in the example occurs *after* the search, it is looping over the
> results.
>
> DK
>
>
> On Fri, Sep 5, 2008 at 4:25 PM, Raj, Senthil <[EMAIL PROTECTED]> wrote:
>
>> If the data is dynamic and especially fetched from the database the no.
>> of children may not be known. Yes if it is E4X, we can dig through the XML
>> path and specify it directly but there are places where looping cannot be
>> avoided.
>>
>> The sample in the specified URL has looping too…
>>
>>
>>
>> for each (var num:XML in [EMAIL PROTECTED]) {
>>
>> trace(num); // 123-123-1234
>>
>> } // 789-789-7890
>>
>>
>>
>>
>>
>>
>> ------------------------------
>>
>> *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On Behalf Of *Douglas
>> Knudsen
>> *Sent:* Friday, September 05, 2008 4:14 PM
>> *To:* [email protected]
>> *Subject:* Re: [AFFUG Discuss] Selective Data in a Data Grid
>>
>>
>>
>> e4x? no looping needed
>> http://livedocs.adobe.com/flex/3/langref/XML.html
>> see this URL for some examples.
>>
>> Also, if you put this data into a ArrayCollection of some sort of objects,
>> hopefully you use typed ones, you can use the filtering methods of
>> ArrayCollection class.
>>
>> DK
>>
>>
>> On Fri, Sep 5, 2008 at 4:06 PM, Raj, Senthil <[EMAIL PROTECTED]>
>> wrote:
>>
>> The XML can be filtered the following way.
>>
>> * *
>>
>> *private* *var* faq:XML = <FAQS>
>>
>> <FAQ id="1" isHeader="1" question="About Flex"
>> answer="" />
>>
>> <FAQ id="2" isHeader="0" question="What *is*the
>> Purpose?" answer="To be awesome" />
>>
>> <FAQ id="3" isHeader="0" question="Who should
>> *use* it?" answer="Everyone!" />
>>
>> <FAQ id="4" isHeader="1" question="About
>> Chattanooga" answer="" />
>>
>> <FAQ id="5" isHeader="1" question="About the
>> Mets" answer="" />
>>
>> <FAQ id="6" isHeader="1" question="About
>> Donkeys" answer="" />
>>
>> <FAQ id="7" isHeader="1" question="About
>> Penguins" answer="" />
>>
>> </FAQS>;
>>
>>
>>
>> ………
>>
>>
>>
>> *for* *each* (*var* item:XML *in*faq.children()){
>>
>> *if* ([EMAIL PROTECTED] == *"0"*) {
>>
>> mx.controls.Alert.show(*"success "*+
>> [EMAIL PROTECTED]);
>>
>> }
>>
>> }
>>
>>
>> ------------------------------
>>
>> *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On Behalf Of *Lucas
>> Golden
>> *Sent:* Friday, September 05, 2008 3:42 PM
>> *To:* [email protected]
>> *Subject:* [AFFUG Discuss] Selective Data in a Data Grid
>>
>>
>>
>> I'm grabbing data from an XML file and am wanting to only display certain
>> nodes in a Datagrid based on a particular value of the XML Node.
>>
>> I've converted the XML over to an ArrayCollection so I can access
>> particular properties of the XML node, I'm just having problems excluding
>> data from it.
>>
>> I'm working on a way to change around the XML (dynamically created from a
>> Database) to see if I can do some array manipulation as a work around, but
>> it'd be nice if I could just exclude it.
>>
>>
>> So, for instance, if I had the following XML:
>>
>>
>> <FAQS>
>> <FAQ id="1" isHeader="1" question="About Flex" answer="" />
>> <FAQ id="2" isHeader="0" question="What is the Purpose?" answer="To be
>> awesome" />
>> <FAQ id="3" isHeader="0" question="Who should use it?"
>> answer="Everyone!" />
>> <FAQ id="4" isHeader="1" question="About Chattanooga" answer="" />
>> <FAQ id="5" isHeader="1" question="About the Mets" answer="" />
>> <FAQ id="6" isHeader="1" question="About Donkeys" answer="" />
>> <FAQ id="7" isHeader="1" question="About Penguins" answer="" />
>> </FAQS>
>>
>>
>> From that XML file, I only want to display the nodes that have a
>> "isHeader" value of 0.
>>
>> Thanks!
>> 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>
>> -------------------------------------------------------------
>>
>>
>> -------------------------------------------------------------
>> 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 FusionLink <http://www.fusionlink.com>
>> -------------------------------------------------------------
>>
>> -------------------------------------------------------------
>> 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 FusionLink <http://www.fusionlink.com>
> -------------------------------------------------------------
>
-------------------------------------------------------------
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
-------------------------------------------------------------