Solved

Flex 3 - Adding an item to a databound combobox

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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.

743 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

13 Experts available now in Live!

Get 1:1 Help Now