0 Replies Latest reply on Oct 13, 2007 8:47 AM by

    Can't use XML namespaces in datagrid?

      I'm using Flex 3 beta 2. When try to bind a datagrid column to an XML element with a namespace, it doesn't display any value. if I try the same XML without a namepace, it works fine. For example, in the simple code below, binding a column with a no-namespace XML document as :
      <mx:DataGridColumn headerText="First" dataField="firstname"/>
      work fine but for the XML case with namespace:
      <mx:DataGridColumn headerText="First" dataField="ex::firstname"/>
      does not display the value.
      The "ex" namespace is declared earlier in the code and I have no problem accessing the values with other controls like text or list box. I actually reported this as a bug but was wondering is anyone has a work around or a similar cse that is working.
      many thanks


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="244">


      <mx:Script>
      <![CDATA[
      import flash.events.*;
      import flash.net.URLLoader;
      import flash.net.URLRequest;

      public var ex:Namespace = new Namespace(" http://www.example.org/dummy");

      [Bindable]
      public var testXML:XML =
      <root>
      <person id="1" initials="JD">
      <firstname>John</firstname>
      <lastname>Doe</lastname>
      </person>
      <person id="2" initials="AB">
      <firstname>Andy</firstname>
      <lastname>Baldwin</lastname>
      </person>
      <person id="3" initials="CD">
      <firstname>Charles</firstname>
      <lastname>Darwin</lastname>
      </person>
      </root>
      ;

      [Bindable]
      public var testXMLNS:XML =
      <root xmlns=" http://www.example.org/dummy">
      <person id="1" initials="JD">
      <firstname>John</firstname>
      <lastname>Doe</lastname>
      </person>
      <person id="2" initials="AB">
      <firstname>Andy</firstname>
      <lastname>Baldwin</lastname>
      </person>
      <person id="3" initials="CD">
      <firstname>Charles</firstname>
      <lastname>Darwin</lastname>
      </person>
      </root>
      ;

      ]]>
      </mx:Script>
      <!-- Without a namespace, the column correctly display the element values -->
      <mx:DataGrid x="10" y="10" width="580" height="106" dataProvider="{testXML.person}">
      <mx:columns>
      <mx:DataGridColumn headerText="ID" dataField="@id"/>
      <mx:DataGridColumn headerText="First" dataField="firstname"/>
      <mx:DataGridColumn headerText="Last" dataField="lastname"/>
      </mx:columns>
      </mx:DataGrid>

      <!-- With a namespace, the column do not display the element values -->
      <mx:DataGrid x="10" y="124" width="580" height="106" dataProvider="{testXMLNS.ex::person}">
      <mx:columns>
      <mx:DataGridColumn headerText="ID" dataField="@id"/>
      <mx:DataGridColumn headerText="First" dataField="ex::firstname"/>
      <mx:DataGridColumn headerText="Last" dataField="ex::lastname"/>
      </mx:columns>
      </mx:DataGrid>

      </mx:Application>