Hi Ben;

 

You can get this to work using the labelFunction property of the DataGridColumn.

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

 

       <mx:Script>

              <![CDATA[

                     import mx.controls.dataGridClasses.DataGridColumn;

                     import mx.collections.XMLListCollection;

              [ Bindable ]

              public var entries:XML =

                                         <rootNode xmlns="http://site.com/Back/DocMetadata">

                                                <Entry>

                                                       <CreateDate>5/5/2006 9:56:30 AM</CreateDate>

                                                       <DocumentType>RPR</DocumentType>

                                                </Entry>

                                                <Entry>

                                                       <CreateDate>5/3/2006 3:07:27 PM</CreateDate>

                                                       <DocumentType>RPR</DocumentType>

                                                </Entry>

                                         </rootNode>;              

             

              public var ns : Namespace = new Namespace( "http://site.com/Back/DocMetadata" );

             

              public function LabelFunctionDate( item : Object, column : DataGridColumn ) : String

              {

                     return XML( item ).ns::CreateDate[ 0 ].toString();

              }

             

              public function LabelFunctionType( item : Object, column : DataGridColumn ) : String

              {

                     return XML( item ).ns::DocumentType[ 0 ].toString();

              }

             

              ]]>

       </mx:Script>

 

       <mx:DataGrid id="myDataGrid" x="10" y="247" width="536" height="230"

              dataProvider="{entries.ns::Entry}">            

              <mx:columns>

                     <mx:DataGridColumn headerText="Column 1" labelFunction="LabelFunctionDate"/>

                     <mx:DataGridColumn headerText="Column 2" labelFunction="LabelFunctionType"/>

              </mx:columns>

       </mx:DataGrid>

 

</mx:Application>

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of ben.clinkinbeard
Sent: Tuesday, June 06, 2006 10:43 AM
To: [email protected]
Subject: [flexcoders] Namespace hell

 

OK, I have posted several times now about problems caused by having
namespaces in XML in Flex (specifically Beta 3), and have gotten
virtually no responses. Please, someone respond, even if to say "I
have the same problem" or "this can't be done". I am beginning to
think that Flex is simply not very capable in this area. I seriously
hope this is not the case.

Default namespaces seem to be the most problematic, as they seem to
prevent the XML from even being used as a DataProvider. Take this
simple setup.

=======================
var entries:XML =
<rootNode xmlns="http://site.com/Back/DocMetadata">
<Entry>
<CreateDate>5/5/2006 9:56:30 AM</CreateDate>
<DocumentType>RPR</DocumentType>
</Entry>
<Entry>
<CreateDate>5/3/2006 3:07:27 PM</CreateDate>
<DocumentType>RPR</DocumentType>
</Entry>
</rootNode>;

namespace d = "http://site.com/Back/DocMetadata";
var list:XMLListCollection = new XMLListCollection(entries.d::Entry);
myDataGrid.dataProvider = list;

<mx:DataGrid id="myDataGrid" x="10" y="247" width="536" height="230">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="CreateDate"/>
<mx:DataGridColumn headerText="Column 2" dataField="DocumentType"/>
</mx:columns>
</mx:DataGrid>
=======================

This results in the DataGrid being populated with 2 items, but there
is no text displayed. You simply have empty rollovers. However, if you
remove the namespace from the xml and update the AS accordingly,
everything works correctly, with text being displayed as expected. Is
this really a shortcoming of Flex or am I missing something really simple?

Thanks,
Ben

__._,_.___

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





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to