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

    populate combobox via rpc and arraycollection

    karel_s
      Hello,

      i have this xml comming in via httpservice.

      <types>
      <Type>
      <TypeId>1</TypeId>
      <TypeUitspraak>Vonnis </TypeUitspraak>
      </Type>
      <Type>
      <TypeId>2</TypeId>
      <TypeUitspraak>Arrest </TypeUitspraak>
      </Type>
      </types>

      here is (part of) the code

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


      [Bindable]
      private var uitspraakTypes:ArrayCollection;

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


      private function InitApp():void
      {
      types.send();
      }


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

      Thanks

      Karel
        • 1. Re: populate combobox via rpc and arraycollection
          batmitra Level 1
          Hi
          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
            vij010 Level 1
            Hi,

            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 :

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

            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:Script>
            <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"/>
            </mx:Panel>
            </mx:Application>

            [/code]

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