Link to home
Start Free TrialLog in
Avatar of coldchillin
coldchillin

asked on

Flex 3 - Adding an item to a databound combobox

I'm trying to add an item to a combobox that is databound. I'm trying to add a first element of "All", but am new to flex. I know how I would do this is ColdFusion, and .Net, but am not sure of the syntax.

A RemoteObject calls a CFC to return a query to populate the combobox, and I need to add a first item of "All" for the field PaymentType.
<mx:ComboBox id="cb_PaymentMethod" dataProvider="{acPaymentMethods}" labelField="PaymentType"/>

Open in new window

Avatar of Jones911
Jones911

var itemAll:Object = new Object();
itemAll.data = "All";
itemAll.label = "All";

acPaymentMethods.addItemAt(itemAll,0);


This will add "All" to the first position.
Avatar of coldchillin

ASKER

I get that above, but how does that fit in with the following framework?

<mx:ComboBox id="cb_PaymentMethod" dataProvider="{acPaymentMethods}" labelField>
 
[Bindable] public var acPaymentMethods:ArrayCollection;
 
                 
 
public function getPaymentMethods():void {
 
   RO.getPaymentMethods();
 
}
 
private function getPaymentMethods_result(event:ResultEvent):void {
 
acPaymentMethods = event.result as ArrayCollection;  
 
                  }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jones911
Jones911

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you! I used a different method to solve the problem (appending the query on the CFC side), but I reallly wanted to know the answer!