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

x
?
Solved

populate combo box in flex via db

Posted on 2009-04-08
3
Medium Priority
?
1,588 Views
Last Modified: 2013-12-24
How would I populate a combo box with data from a cfc?  I have an array below but they are hard coded.  The cfc is built to return the data.  Just need to know now to populate the combo box with the query data.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="ro.getData()"  viewSourceURL="srcview/index.html" height="100%" borderStyle="none" width="100%">
	<mx:RemoteObject id="ro" destination="ColdFusion" showBusyCursor="true" source="Media.components.Crud">
		<mx:method name="getData" result="getDataResult(event)" />
		<mx:method name="saveNewData" result="getDataResult(event)" />
		<mx:method name="saveOldData" result="getDataResult(event)" />
		<mx:method name="deleteData" result="getDataResult(event)" />
	</mx:RemoteObject>
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.rpc.events.ResultEvent;
			
			private var isNew:Boolean = true;
			
			public function getDataResult(e:ResultEvent):void{
				dg.dataProvider = e.result as ArrayCollection;
				makeNew();
				
			}
			private function makeNew():void{
				firstNameFld.text = "";
				lastNameFld.text = "";
				officePhoneFld.text = "";
				isNew = true;
			}
			private function save():void{
				if(isNew){
					ro.saveNewData(firstNameFld.text,lastNameFld.text,officePhoneFld.text);
				}else{
					ro.saveOldData(firstNameFld.text,lastNameFld.text,officePhoneFld.text,dg.selectedItem.id);
				}
			}
			private function deleteData():void{
				if(dg.selectedIndex > -1 )ro.deleteData(dg.selectedItem.id);
			}
		]]>
	</mx:Script>
	<mx:Label text="View your data below." width="1148" height="25" color="#FFFFFF" fontSize="12" fontFamily="Verdana" fontWeight="bold" id="toptext"/>
	<mx:Panel width="1148" height="784" layout="absolute">
		<mx:DataGrid x="10" y="10" width="1108" height="316" id="dg" change="isNew = false">
		</mx:DataGrid>
		<mx:Panel x="10" y="409" width="1108" height="286" layout="absolute">
			<mx:FormItem label="First Name" id="firstnameLbl" x="10" y="10">
				<mx:TextInput id="firstNameFld" text="{dg.selectedItem.firstNameFld}"/>
			</mx:FormItem>
			<mx:FormItem label="Last Name" id="lastnameLbl" x="11" y="40">
				<mx:TextInput id="lastNameFld" text="{dg.selectedItem.lastNameFld}"/>
			</mx:FormItem>
			<mx:FormItem label="Office Phone" id="officephoneLbl" x="10" y="70" width="266">
				<mx:TextInput id="officePhoneFld" text="{dg.selectedItem.officePhoneFld}" width="176"/>
			</mx:FormItem>
			<mx:FormItem label="Market" id="marketLbl" x="10" y="100" width="266">
				<mx:ComboBox> 
      <mx:ArrayCollection>
         <mx:String>AK</mx:String>
         <mx:String>AL</mx:String>
         <mx:String>AR</mx:String>
      </mx:ArrayCollection>
   </mx:ComboBox>
 
 
			</mx:FormItem>
		</mx:Panel>
		<mx:Button x="10" y="712" label="Save Record" click="save()"/>
		<mx:Button x="1011" y="712" label="Delete Record" click="deleteData()"/>
		<mx:Button x="115" y="712" label="Add New Record" click="makeNew()"/>
		<mx:Label x="105" y="334" text="Click on the record which will populate the fields below. After making your changes, click Save Record." width="1013" height="25" color="#990000" fontSize="11" fontFamily="Verdana" fontWeight="normal" id="midtext"/>
		<mx:Label x="10" y="334" text="Edit A Record:" width="97" height="25" color="#990000" fontSize="11" fontFamily="Verdana" fontWeight="bold" id="midtext0"/>
		<mx:Label x="130" y="355" text="Click Add New Record to clear all fields.  Enter new data, then click Save Record." width="988" height="25" color="#990000" fontSize="11" fontFamily="Verdana" fontWeight="normal" id="midtext1"/>
		<mx:Label x="10" y="355" text="Add New Record:" width="123" height="25" color="#990000" fontSize="11" fontFamily="Verdana" fontWeight="bold" id="midtext2"/>
		<mx:Label x="115" y="376" text="Click on the record above.  Then click Delete Record." width="1003" height="25" color="#990000" fontSize="11" fontFamily="Verdana" fontWeight="normal" id="midtext3"/>
		<mx:Label x="10" y="376" text="Delete Record:" width="112" height="25" color="#990000" fontSize="11" fontFamily="Verdana" fontWeight="bold" id="midtext4"/>
	</mx:Panel>
</mx:Application>

Open in new window

0
Comment
Question by:COwebmaster
[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
3 Comments
 
LVL 19

Accepted Solution

by:
erikTsomik earned 2000 total points
ID: 24100538
0
 

Author Closing Comment

by:COwebmaster
ID: 31568189
Thanks!
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24101687
thank you
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

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