Solved

Flex 3 - Adding an item to a databound combobox

Posted on 2009-07-09
4
290 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now