2 Replies Latest reply on Jun 5, 2007 12:49 AM by vij010

    populate combobox via rpc and arraycollection


      i have this xml comming in via httpservice.

      <TypeUitspraak>Vonnis </TypeUitspraak>
      <TypeUitspraak>Arrest </TypeUitspraak>

      here is (part of) the code

      import mx.collections.ArrayCollection;
      import mx.rpc.events.*;

      private var uitspraakTypes:ArrayCollection;

      private function typesHandler(event:ResultEvent):void{
      uitspraakTypes =event.result.types.Type;

      private function InitApp():void

      <mx:HTTPService id="types" url=" http://www.emis.vito.be/SBO/haaltypes.asp" result="typesHandler(event)"/>

      <mx:ComboBox id="typeUitspraak" dataProvider="{uitspraakTypes}"></mx:ComboBox>

      in debug mode i can see the arraycollection in filled in correctly
      I want to bind TypeUitspraak node of the xml to the combobox.
      I get [object Object] in my combobox.

      Please tell me what am i missing here.


        • 1. Re: populate combobox via rpc and arraycollection
          batmitra Level 1
          you ares simply missing the one important thing

          ComboBox uses a property called labelfield to show your field, sou you have to pass it a dataprovider, your arraycollection , and a labelfield, in your case TypeUitspraak
          • 2. Re: populate combobox via rpc and arraycollection

            I also have the same problem, but the data is correctly binded, I am able to refresh the text box from the Combo (which is the correct logic), but unfortunately, the combo only shows [object,object] everywhere.

            I was reading the forum when I got this answer that I found, but I am still unable to code it in, I am attaching my code here :

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="xmldata.send();">
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.utils.ObjectUtil;
            import mx.controls.Alert;

            public var mxdata:ArrayCollection;

            public function httpHandler(event:ResultEvent):void{
            //the property lastresult dumps the object in the application then the xpath allows you to get the propertysa you want...
            mxdata = xmldata.lastResult.RECORDS.RECORD;

            private function server_fault(event:FaultEvent):void
            Alert.show( ObjectUtil.toString(event.fault) );
            <mx:HTTPService url="usjdata.xml" id="xmldata" result="httpHandler(event)" fault="server_fault(event)"/>
            <mx:Panel x="10" y="10" width="544" height="446" layout="absolute">
            <mx:DataGrid dataProvider="{mxdata}" y="11" x="10" width="503" editable="false" enabled="true"/>
            <mx:ComboBox dataProvider="{mxdata}" labelField="{selectedData.selectedItem.year}" x="231" y="171" id="selectedData"/>
            <mx:TextArea text="{selectedData.selectedItem.dtext}" width="503" height="166" enabled="true" editable="false" wordWrap="true" x="12" y="212" fontAntiAliasType="advanced" fontGridFitType="pixel" fontSharpness="1"/>


            The DataGrid is populating correctly, the text box refreshes correctly, the only problem is the display of the combo, i want the year to come as options in the combo, but instead of that I get [Object,objec]. Hope someone can help....