10 Replies Latest reply on Dec 26, 2008 1:15 PM by Newsgroup_User

    When the combobox is rendered all the values displayed look like [object Object].

    nikos101 Level 2
      I wasn't sure where to post this so please forgive me.

      I am trying to populate a combobox with a series of values returned from a Coldfusion method that retrives a resault froma database. Basically all the data from a table of staff.

      <cffunction name="getUsers" access="remote" returntype="array">
      <cfquery name="q" datasource="#datasource#">
      SELECT *
      FROM STAFF_CHARTS_STAFF_TEMP
      </cfquery>

      <cfset aRecordset= querytoarray(q)>
      <cfset flash.result=aRecordset>
      <cfreturn flash.result>
      </cffunction>




      <cffunction name="querytoarray" returntype="array" output="No">
      <cfargument name="q" required="Yes" type="query">
      <cfset var aTmp = arraynew(1)>

      <cfif q.recordcount>
      <cfloop query="q">
      <cfset stTmp = structNew()>
      <cfloop list="#lcase(q.columnlist)#" index="col">
      <cfset stTmp[col] = q[col][currentRow]>
      </cfloop>

      <cfset arrayAppend(aTmp,stTmp)>
      </cfloop>
      <cfelse>
      <cfset stTmp = structNew()>
      <cfloop list="#lcase(q.columnlist)#" index="col">
      <cfset stTmp[col] = "">
      </cfloop>

      <cfset arrayAppend(aTmp,stTmp)>
      </cfif>

      <cfreturn aTmp>
      </cffunction>


      The result from a call of CF method getUsers is set as the data provider to ComboBox with id = "cb"

      <mx:RemoteObject
      id="myService"
      destination="ColdFusion"
      source="staff_ratings.staff_Ratings-debug.staff"
      showBusyCursor="true">
      <mx:method name="getUsers" result="handleResult(event)" fault="Alert.show(event.fault.message)"/>
      </mx:RemoteObject>



      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;

      [Bindable]
      public var sResult:Array;

      public function handleResult(event:ResultEvent):void{
      sResult=event.result as Array;
      cb.dataProvider=sResult;
      }

      ]]>
      </mx:Script>

      However when the combobox is rendered all the values displayed look like [object Object].

      I think the problem is that the result is a array of arrays so I need to find away to ectract a particular colun of data into the combobox

      How do I fix this?