Solved

Flex 3 - Adding an item to a databound combobox

Posted on 2009-07-09
4
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SWF capture the time on the Video 3 234
how can flash builder 4.X version make use of java 8 5 387
Advertising design for my own Purpose 5 93
Flash Converter 8 137
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

726 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