7 Replies Latest reply on Oct 18, 2006 11:08 AM by aBill

    RemoteObject / ComboBox

    GeorgeWS Level 1
      I am having trouble filling in a combobox with my remoteobject. Im thinking I need to retrieve the RO into an ArrayCollection. but im not sure how this would look. Can someone show me a sample? In my app if I hard code an array with data and labels it works fine.

      I have a RO like:

      <mx:RemoteObject id="Brands" destination"COLDFUSION" source="Inv" showBusyCursor="true"/>

      I have a ComboBox:

      <mx:comboBox id='brandfilter' dataprovider="{Brands.Brands.data}"/>

      I have a CFC:

      <cffunction name="Brands" access="remote" returnType="query" output="false">
      <cfquery name="Brands" datasource="myDatasource">
      Select distinct brandid as data , branddesc as label
      From Inv
      </query>
      <cfreturn Brands>
      </cffunction>
        • 1. Re: RemoteObject / ComboBox
          aBill Level 1
          HI,

          We just tried returmType= query to fill the combobox without any issue. What did you get in you combobox? You saw [object object] or nothing at all

          William Chan
          • 2. Re: RemoteObject / ComboBox
            GeorgeWS Level 1
            yes i get [object object]. Im thinking that I need to call out the RO with the creationcomplete to my initVars function. but not sure. Im having a hard time making a new project to test this.
            • 3. Re: RemoteObject / ComboBox
              aBill Level 1
              Hi

              If you see [Object Object], i believe if is the labelField problem. Please turn on debug to see the property name is lowercase "label" . Otherwise, you have to add labelField to your combobox

              William Chan
              • 4. Re: RemoteObject / ComboBox
                GeorgeWS Level 1
                You had know issues? Can you show me you code. or what you did to fill the ComboBox. i cant get the syntax right.
                • 5. RemoteObject / ComboBox
                  aBill Level 1
                  Hi,

                  This is how the labelField work.
                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="initApp()">

                  <mx:Script>
                  <![CDATA[
                  import mx.collections.*;

                  public var mylist:Array ;
                  private function initApp():void
                  {
                  mylist = [ {LABEL:"a",data:[{label:"a1",data:1}, {label:"a2",data:2},{label:"a3",data:3}]},
                  {LABEL:"b",data:[{label:"b1",data:1}, {label:"b2",data:1},{label:"b3",data:1}]},
                  {LABEL:"c",data:[{label:"c1",data:1}, {label:"c2",data:1},{label:"c3",data:1}]},
                  {LABEL:"d",data:[{label:"d1",data:1}, {label:"d2",data:1},{label:"d3",data:1}]}] ;
                  cb.dataProvider = new ArrayCollection(mylist);
                  }
                  ]]>
                  </mx:Script>
                  <mx:ComboBox id="cb" labelField="LABEL" />
                  <mx:List id="listbox" width="100" dataProvider="{cb.selectedItem.data}"/>
                  </mx:Application>

                  However, it still has to verify the data from your remote call. You can turn on debug by modifying WEB-INF/flex/services-config.xml
                  <target class="flex.messaging.log.ConsoleTarget" level="Debug">
                  Then, you should able to see the debug messages, you can find the actual data type and the properties. or If you are using debug player, add <mx:TraceTarget /> to your mxml file. You should able to see the deserialization message log on flashlog.txt

                  William Chan
                  • 6. Re: RemoteObject / ComboBox
                    GeorgeWS Level 1
                    Thanks,
                    It not really the combobox that is not working. I want to know how to get the RemoteObject into and Array so there is a label: and data:. I know that comnobox works because if I hard code and Array like you have done the ComboBox works fine. I just cant find anywhere how to make, get , call? an Array out of the RemoteObject (also that I know works) and has the 2 fields in the CFC renamed to data and label. Any thoughts would be great

                    George
                    • 7. Re: RemoteObject / ComboBox
                      aBill Level 1
                      HI,

                      I overlooked your code. I thought it was data problem! I should read through you code! Sorry!
                      I think you didn't make a remote procedure call. you should call it before you can get the result
                      You have to call Brands.Brands.send() , you can call it in creationComplete

                      then you should get it to work with the lastResult property
                      <mx:comboBox id='brandfilter' dataprovider="{Brands.Brands.lastResult}"/>

                      William Chan