Well the first part is you don't set the text property on a Combobox to fill
it with the items you need. You set what's caleld the "DataProvider" to the
combo box and it takes whatever is in that and puts it into the combo box.
The second part is that you can't set the dataProvider right off the bat if
you need it to be populate from CF. You need to add the items to the
combobox inside of the result function from your CFC. (Hint: your CFC should
be returning a result of all the items you want inside of your combo box) So
once you have a function for your result you can do a for loop on the length
of the result and add the items 1 by 1 into the combo box using a syntax
similiar to this.

private function popCombo(event:ResultEvent):void {
    for(var i:int = 0 ; i < event.result.length; i++){
         myCombo.dataProvider.addItem({label:event.result[i].TITLE, data:
event.result[i].ID}
    }
}

If the items inside of your combo box are always going to be the same values
though and very rarely change you might just consider using an
ArrayCollection and then inside of your JobSearch.mxml file you can set the
dataProvider of the combo box to that ArrayCollection. That would like
something like this. <mx:ComboBox dataProvider="{jobData}"></mx:ComboBox>
(jobData is the name of the ArrayCollection)

On 3/1/07, April <[EMAIL PROTECTED]> wrote:

  Hi there,

We are using CF with Flex but are not using the Flex Data Service. I'm
very much a newb
and I'm having trouble finding any information on how to populate
controles from a
database without using Flex Data Service. Any help would be greatly
appreciated.

First I have a page... JobSearch.mxml that contains a combo box that I
want to populate
with the job_id and job_title from a MSSQL database.

In Flex in the RDS DataView I used the "Create CFC" Wizard which generated
"job.cfc" and
"jobGateway.cfc". It also generated "job.as".

The CF Function that selects the data appears to be defaulted and called
"load" and the .as
function is called simply "job".

So, that all looks great. But I can't find any information on what I need
to have on my
JobSearch.mxml to actually get this data into the comboBox.

I did:

<mx:Script>
<![CDATA[

[Bindable]
public var jobData:job = null;

]]>
</mx:Script>

And then:
<mx:ComboBox text="{jobData.job_title}"></mx:ComboBox>

But I'm being told "Type was not found or was not a complie-time constant:
job"

I guess I'm missing something, or doing something way wrong... I just
don't know enough
of Flex at this point to know what it is.

Thanks!

April

Reply via email to