Solved

Flex 3 - Adding an item to a databound combobox

Posted on 2009-07-09
4
291 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:coldchillin
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 24815061
var itemAll:Object = new Object();
itemAll.data = "All";
itemAll.label = "All";

acPaymentMethods.addItemAt(itemAll,0);


This will add "All" to the first position.
0
 
LVL 1

Author Comment

by:coldchillin
ID: 24815353
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

0
 
LVL 19

Accepted Solution

by:
Jones911 earned 500 total points
ID: 24815396
Like this:
private function getPaymentMethods_result(event:ResultEvent):void {
   acPaymentMethods = event.result as ArrayCollection;  
   var itemAll:Object = new Object();
   itemAll.data = "All";
   itemAll.label = "All";
   acPaymentMethods.addItemAt(itemAll,0);
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:coldchillin
ID: 31601680
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!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question