Below is a sample app that uses labelFunction to access nested xml node
values.

Also note the dataProvider specification:
dataProvider="{gXMLDoc.firstChild.childNodes}".  DataGrids want an array
as a dataProvider, childNodes provides one.

http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectI
D=258

Tracy


-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of flexcoder1
Sent: Tuesday, July 12, 2005 10:22 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] display nested xml in a datagrid

Hi. Can someone help with this question?  It is driving me crazy!
(the entire example is at the bottom of this post)

There is more to this problem but I have tried to simplify it to the 
basic question below:

Say I have the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<Items>
<Item Id="1" Title="Title1">
        <Status Id="1" Name="Active" />
</Item>
<Item Id="2" Title="Title2">
        <Status Id="2" Name="Inactive" />
</Item>
</Items>


How can I display the current status name of each item in a data 
grid?
I have tried:

<mx:DataGrid id="gridStory" dataProvider="{mx.utils.ArrayUtil.toArray
( GetItems.result.Items.Item)}" width="100%" height="100%">     
        
<mx:columns>
<mx:Array>
        <mx:DataGridColumn columnName="Id" />
        <mx:DataGridColumn columnName="Title" />
        <mx:DataGridColumn columnName="Status" /> shows object 
Object - I want the item's Status.Name to appear
        <mx:DataGridColumn columnName="Status.Name" /> **** THIS 
DOES NOT WORK ****
</mx:Array>
</mx:columns>
</mx:DataGrid>

How can I show the status?  If I just use 
        <mx:DataGridColumn columnName="Status" />

the grid displays (as expected) object Object.  Also, for this 
particular xml file it is not an option to just collapse the Status 
subtags into the Item tag and have something like:

<Item Id="2" Title="Title2" StatusId="2" StatusName="Inactive" />  
*** For reasons outside scope of question I cannot do this ***
I know the above works correctly.


Thanks for any help with this. Below is the entire example:

test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
<mx:Model id="modItems" source="simple.xml">
</mx:Model>
<mx:DataGrid id="gridStory" dataProvider="{modItems.Item}" 
width="100%" height="100%">             
<mx:columns>
<mx:Array>
        <mx:DataGridColumn columnName="Id" />
        <mx:DataGridColumn columnName="Title" />
        <mx:DataGridColumn columnName="Status" />
        <mx:DataGridColumn columnName="Status.Name" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>

simple.xml
<?xml version="1.0" encoding="utf-8"?>
<Items>
<Item Id="1" Title="Title1">
        <Status Id="1" Name="Active" />
</Item>
<Item Id="2" Title="Title2">
        <Status Id="2" Name="Inactive" />
</Item>
</Items>


Thanks for any help.





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to