Title: F2B3: Repeater with e4x XMLList as dataprovider - type conversion error. DataGrid works fine

I am trying to use e4x XML to populate a mx:Repeater, but am getting a  runtime type conversion error:

TypeError: Error #1034: Type Coercion failed: cannot convert [EMAIL PROTECTED] to mx.collections.ArrayCollection.

        at mx.core::Repeater/set dataProvider()

The same dataProvider drives a DataGrid just fine.

A small sample app showing this is below.  Any ideas will be appreciated.

Tracy Spratt

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

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

    layout="absolute"

          creationComplete="initApp()">

<mx:Script><![CDATA[   

        [Bindable]

        private var _xmlUsers:XML;

        private function initApp():void

        {

                _xmlUsers =

      <users>

        <user>

          <username gender="male">Joe</username>

          <useremail>[EMAIL PROTECTED]</useremail>

        </user>

        <user>

          <username gender="female">Maggie</username>

          <useremail>[EMAIL PROTECTED]</useremail>

        </user>

      </users>

        }//initApp     

]]></mx:Script>

  <mx:VBox>

    <mx:HBox>

      <mx:Label text="Repeater:" />

      <mx:VBox>

         <mx:Repeater dataProvider="{_xmlUsers.user}" id="r">

          <mx:HBox>

             <mx:Label text="{r.currentItem.username}"/>

            <mx:Label text="{r.currentItem.useremail}"/>         

          </mx:HBox>

        </mx:Repeater>     

      </mx:VBox>

    </mx:HBox>

    <mx:HBox>

      <mx:Label text="DataGrid:" />  

      <mx:DataGrid dataProvider="{_xmlUsers.user}" >

        <mx:columns>

          <mx:Array>

            <mx:DataGridColumn headerText="Name" dataField="username" />

            <mx:DataGridColumn headerText="Email" dataField="useremail" />

          </mx:Array>

        </mx:columns>

      </mx:DataGrid>

    </mx:HBox> 

  </mx:VBox>

</mx:Application>



--
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