1 Reply Latest reply on May 30, 2007 12:48 PM by vaporboy

    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
        • 1. Re: ArrayCollections
          vaporboy Level 1
          gregtan, i am having the same issue. It seems that if you get one record, putting in an arraycollection doesn't work. I wonder if Flex is reading that data as something else so that it cannot be assigned to the collection. I have seen this issue elsewhere on the web but have not found a solution yet, have you?