3 Replies Latest reply on Dec 11, 2007 7:46 PM by 2JZ

    ArrayCollections

    gregtan
      Hi there,

      I am new to flex. I am working with arraycollection (as a dataprovider) to populate a list control with the dynamically generated XML ( generated as a result of query to a mysql database using PHP). The list control is getting populated if the generated XML contains more than one node (say 2,3...), but it is failing to get populated if the returned XML contains only one child node. Please help me out.

      MXML Snippet:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="gridhttp.send()">
      <mx:Script>
      <![CDATA[
      [Bindable]
      public var userStoresList:ArrayCollection = new ArrayCollection();

      public function getuserStoresList(event:ResultEvent):void
      {
      userStoresList = event.result.allUnits.unit;
      }
      ]]>
      </mx:Script>
      <mx:HTTPService id="gridhttp" url="xmlone.xml" result="getuserStoresList(event)" />
      <mx:List id="fetchedGridsList" dataProvider="{userStoresList}" />
      </mx:Application>

      xmlone.xml:

      <?xml version="1.0" encoding="utf-8"?>
      <allUnits>
      <unit>
      <unitName>Bunch</unitName>
      <unitID>4</unitID>
      </unit>
      <unit>
      <unitName>Bunch</unitName>
      <unitID>5</unitID>
      </unit>
      </allUnits>

      If i remove the second node, with unitID=5 and recompile my mxml, the list control fails to get populated.
      Please do help me...

      Thanks in advance,
      Tan