Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Flex 3 - Adding an item to a databound combobox

Posted on 2009-07-09
4
Medium Priority
?
304 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 2000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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…
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 what frame rate is, how to control it and what effect it has on the video.

618 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