flex datagrid and combobox

I have a flex datagrid and some form fields including 2 combo boxes.  Both combo boxes pull in data from my db table.  both are bindable to the datagrid so that when you click on the record in the grid, the item in the combo box is highlighted.  That works great.  However, inside the datagrid, what is being passed back to the grid is the pk id.  It needs to be the other field in the db table.  What would I need to change?
flex app:
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:ns1="*" 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="getcbData" result="getCBData(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:RemoteObject id="agency" destination="ColdFusion" showBusyCursor="true" source="Media.components.VideoProfessor.Agency2">
		<mx:method name="getagencyData" result="getagencyData(event)" />
	</mx:RemoteObject>
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.collections.ArrayCollection;
			
			[Bindable] private var gridData:ArrayCollection;
			[Bindable] private var cbData:Array;
			[Bindable] private var agencyData:Array;
			
			
			//on initialize, populate grid and combo boxes!
			private function init():void{
				ro.getData();
				ro.getcbData();
				agency.getagencyData();
			}
			
			private var isNew:Boolean = true;
			
			public function getDataResult(e:ResultEvent):void{
				dg.dataProvider = e.result as ArrayCollection;
				makeNew();
				
			}
			
			private function getCBData(e:ResultEvent):void{
				cbData = e.result as Array;
			}
			
			private function getagencyData(e:ResultEvent):void{
				agencyData = e.result as Array;
			}
			
			private function makeNew():void{
				firstNameFld.text = "";
				lastNameFld.text = "";
				officePhoneFld.text = "";
				agencyId.text = "";
				isNew = true;
			}
			private function save():void{
				if(isNew){
					ro.saveNewData(firstNameFld.text,lastNameFld.text,officePhoneFld.text,agencyId.text);
				}else{
					ro.saveOldData(firstNameFld.text,lastNameFld.text,officePhoneFld.text,agencyId.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 dataProvider="{gridData}" 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">
			
			<!-- fill with first names -->
			<mx:FormItem label="First Name" id="firstnameLbl" x="10" y="70" width="266">
				<ns1:comboBox id="firstNameFld" x="106" y="126"  dataProvider="{cbData}" selectedValue="{dg.selectedItem.firstNameFld}"/>
			</mx:FormItem>
			
			<!-- fill with agency names -->
			<mx:FormItem label="agency" id="agencyLbl" x="305" y="70" width="266">
				<ns1:comboBox id="agencyId" x="106" y="126"  dataProvider="{agencyData}" selectedValue="{dg.selectedItem.agencyId}"/>
			</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="305" y="40" width="266">
				<mx:TextInput id="officePhoneFld" text="{dg.selectedItem.officePhoneFld}" width="176"/>
			</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>
 
 
Crud.cfc:
<cfcomponent output="false">
	
	<!--- get all data; populate in grid --->
	<cffunction name="getData" access="remote" returntype="Query">
		<cfset var local = {} />
		<cfquery name="local.q" datasource="media">
			select		id, firstNameFld, lastNameFld, officePhoneFld, agencyId
			from		employees
		</cfquery>
		<cfreturn local.q/>
	</cffunction>
	
	
	
	
	<!--- get agencies; populate combo box --->
	<cffunction name="getagencyData" access="remote" returntype="array">
		<cfset local = {} />
		
		<cfquery datasource="media" name="local.q">
			select		*
			from		agency
		</cfquery>
		
		<cfset local.result = arrayNew(1) />
		
		<cfloop query="local.q">
			<cfset local.temp = {} />
			<cfset local.temp['data'] = local.q.agencyId />
			<cfset local.temp['label'] = local.q.agency />
			<cfset arrayAppend(local.result,local.temp) />
		</cfloop>
		
		<cfreturn local.result />
	</cffunction>
	
 
 
 
	
	<!--- get First Name; populate combo box --->
	<cffunction name="getcbData" access="remote" returntype="array">
		<cfset local = {} />
		
		<cfquery datasource="media" name="local.q">
			select		firstNameFld
			from		employeesNames
		</cfquery>
		
		<cfset local.result = arrayNew(1) />
		
		<cfloop query="local.q">
			<cfset local.temp = {} />
			<cfset local.temp['data'] = local.q.firstNameFld />
			<cfset local.temp['label'] = local.q.firstNameFld />
			<cfset arrayAppend(local.result,local.temp) />
		</cfloop>
		
		<cfreturn local.result />
	</cffunction>
	
	
	
	
	<!--- save new record --->
	<cffunction name="saveNewData" access="remote" returntype="Query">
		<cfargument name="firstNameFld" type="string" required="true"/>
		<cfargument name="lastNameFld" type="string" required="true"/>
		<cfargument name="officePhoneFld" type="string" required="true"/>
		<cfargument name="agencyId" type="string" required="true"/>
		
		<cfquery datasource="media">
			insert		
			into		employees
						( firstNameFld, lastNameFld, officePhoneFld, agencyId)
			values		( <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstNameFld#"/>,
						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastNameFld#"/>,
						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.officePhoneFld#"/>,
						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.agencyId#"/> )
		</cfquery>
		<cfreturn getData() />
	</cffunction>
	
	
	
	
	<!--- save existing record --->
	<cffunction name="saveOldData" access="remote" returntype="Query">
		<cfargument name="firstNameFld" type="string" required="true"/>
		<cfargument name="lastNameFld" type="string" required="true"/>
		<cfargument name="officePhoneFld" type="string" required="true"/>
		<cfargument name="agencyId" type="string" required="true"/>
		<cfargument name="id" type="Numeric" required="true" />
		
		<cfquery datasource="media">
			update		employees		
			set			firstNameFld = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstNameFld#" />,
						lastNameFld = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastNameFld#" />,
						officePhoneFld = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.officePhoneFld#" />,
						agencyId = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.agencyId#" />
			where		id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.id#" />
		</cfquery>
		<cfreturn getData() />
	</cffunction>
	
	
	
	<!--- delete record --->
	<cffunction name="deleteData" access="remote" returntype="Query">
		<cfargument name="id" type="string" required="true">
		
		<cfquery datasource="media">
			delete
			from		employees
			where		id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.id#" />
		</cfquery>
		<cfreturn getData() />
	</cffunction>
		
</cfcomponent>
 
 
 
Agency2.cfc:
<cfcomponent output="false">
	
	<!--- get agencies; populate combo box --->
	<cffunction name="getAgencyData" access="remote" returntype="array">
		<cfset local = {} />
		
		<cfquery datasource="media" name="local.q">
			select		*
			from		agency
		</cfquery>
		
		<cfset local.result = arrayNew(1) />
		
		<cfloop query="local.q">
			<cfset local.temp = {} />
			<cfset local.temp['data'] = local.q.agencyId />
			<cfset local.temp['label'] = local.q.agencyId />
			<cfset arrayAppend(local.result,local.temp) />
		</cfloop>
		
		<cfreturn local.result />
	</cffunction>
	
</cfcomponent>

Open in new window

COwebmasterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSr. Software engineerCommented:
>> However, inside the datagrid, what is being passed back to the grid is the pk id.  
>> It needs to be the other field in the db table.  What would I need to change?
I don't understand what you're trying to say.
Could you please explain it in other words?
0
COwebmasterAuthor Commented:
In my db table (called agency), I have 2 columns (agencyId, agency).   My combo box in my flex app show the agencyId, not agency.  Can you please explain what I should change in my flex code or cfcs to make it so that the combo box show the correct column.  Also, the column in the datagrid is also displaying agencyId when it should be pulling in agency data from my db table.
0
zzynxSr. Software engineerCommented:
>> Also, the column in the datagrid is also displaying agencyId when it should be pulling in agency data from my db table.
When I read the lines 12 & 13 of your code and I read the lines 250 & 251 I see why.
Change line 251 being

      <cfset local.temp['label'] = local.q.agencyId />

into

      <cfset local.temp['label'] = local.q.agency />
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

zzynxSr. Software engineerCommented:
Mistake: changing that line 251 as I mentioned is to resolve the combo box problem.
Still thinking about the datagrid problem...
0
zzynxSr. Software engineerCommented:
Concerning the datagrid:
In lines 117/118 I see that your query agencyId, not agency

117                  select            id, firstNameFld, lastNameFld, officePhoneFld, agencyId
118                  from            employees
0
COwebmasterAuthor Commented:
Ok, I fixed all that but now when I click on the record in the datagrid, the item doesn't get selected in the drop down.  In the drop down, I can select another item and click Save Record which works so that good.  Plus I can see the agencies in the drop down and in the datagrid.  Just that last part and we should on our way.
0
COwebmasterAuthor Commented:
Also, on the Save button, the agencyId is not being saved to the table, but the agency.  It's needs to the agencyId (datatype int in the table).
0
COwebmasterAuthor Commented:
ok, forget that problem with the drop down item not being highlighted.  It was because the record is insrting a string.
0
COwebmasterAuthor Commented:
The last problem I see is my last point and that is its insrting agency (string) into the table but it needs to insrt the agencyId.
0
zzynxSr. Software engineerCommented:
>> It's needs to the agencyId (datatype int in the table).
Then why does line 180 reads:

            <cfargument name="agencyId" type="string" required="true"/>

?
0
COwebmasterAuthor Commented:
yea, that true that needs changed.  however, it's still not passing a numeric value into the table.
0
COwebmasterAuthor Commented:
Ok, I changed that string to numeric in the crud.cfc:
<cfcomponent output="false">
	
	<!--- get all data; populate in grid --->
	<cffunction name="getData" access="remote" returntype="Query">
		<cfset var local = {} />
		<cfquery name="local.q" datasource="media">
			select		ME.*, A.*
			from		employees ME, agency A
			where ME.agencyId = A.agencyId
		</cfquery>
		<cfreturn local.q/>
	</cffunction>
	
	<!--- get First Name; populate combo box --->
	<cffunction name="getcbData" access="remote" returntype="array">
		<cfset local = {} />
		
		<cfquery datasource="media" name="local.q">
			select		firstNameFld
			from		employeesNames
		</cfquery>
		
		<cfset local.result = arrayNew(1) />
		
		<cfloop query="local.q">
			<cfset local.temp = {} />
			<cfset local.temp['data'] = local.q.firstNameFld />
			<cfset local.temp['label'] = local.q.firstNameFld />
			<cfset arrayAppend(local.result,local.temp) />
		</cfloop>
		
		<cfreturn local.result />
	</cffunction>
	
	<!--- save new record --->
	<cffunction name="saveNewData" access="remote" returntype="Query">
		<cfargument name="firstNameFld" type="string" required="true"/>
		<cfargument name="lastNameFld" type="string" required="true"/>
		<cfargument name="officePhoneFld" type="string" required="true"/>
		<cfargument name="agencyId" type="numeric" required="true"/>
		
		<cfquery datasource="media">
			insert		
			into		employees
						( firstNameFld, lastNameFld, officePhoneFld, agencyId)
			values		( <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstNameFld#"/>,
						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastNameFld#"/>,
						  <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.officePhoneFld#"/>,
						  <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.agencyId#"/> )
		</cfquery>
		<cfreturn getData() />
	</cffunction>
	
	<!--- save existing record --->
	<cffunction name="saveOldData" access="remote" returntype="Query">
		<cfargument name="firstNameFld" type="string" required="true"/>
		<cfargument name="lastNameFld" type="string" required="true"/>
		<cfargument name="officePhoneFld" type="string" required="true"/>
		<cfargument name="agencyId" type="numeric" required="true"/>
		<cfargument name="id" type="Numeric" required="true" />
		
		<cfquery datasource="media">
			update		employees		
			set			firstNameFld = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstNameFld#" />,
						lastNameFld = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastNameFld#" />,
						officePhoneFld = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.officePhoneFld#" />,
						agencyId = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.agencyId#" />
			where		id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.id#" />
		</cfquery>
		<cfreturn getData() />
	</cffunction>
	
	<!--- delete record --->
	<cffunction name="deleteData" access="remote" returntype="Query">
		<cfargument name="id" type="string" required="true">
		
		<cfquery datasource="media">
			delete
			from		employees
			where		id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.id#" />
		</cfquery>
		<cfreturn getData() />
	</cffunction>
		
</cfcomponent>

Open in new window

0
COwebmasterAuthor Commented:
So I guess what I need to figure out is how can I display (label) the agency in the drop down but insert the agencyId (data)?
0
zzynxSr. Software engineerCommented:
OK. And does that help?
0
zzynxSr. Software engineerCommented:
>> So I guess what I need to figure out is how can I display (label) the agency in the drop down but insert the agencyId (data)?
You need to fill up your combo with agencyid's and use a labelfunction that "translate's" the agencyId into the agency
0
COwebmasterAuthor Commented:
can't get it work.  It throws an error.
0
zzynxSr. Software engineerCommented:
>> It throws an error.
Mmmm, that's not very informative... ;o)
Complete error message? At what line?
0
COwebmasterAuthor Commented:
Sorry, this is the error I get when the page loads is:

Error #1081: Property @agencyId not found on Object and there is no default value
flex app:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" xmlns:ns1="*" viewSourceURL="srcview/index.html" height="100%" borderStyle="none" width="100%">
	<!-- Crud.cfc -->
	<mx:RemoteObject id="ro" destination="ColdFusion" showBusyCursor="true" source="Media.components.Crud">
		<mx:method name="getData" result="getDataResult(event)" />
		<mx:method name="getcbData" result="getCBData(event)" />
		<mx:method name="saveNewData" result="getDataResult(event)" />
		<mx:method name="saveOldData" result="getDataResult(event)" />
		<mx:method name="deleteData" result="getDataResult(event)" />
	</mx:RemoteObject>
	<!-- Agency2.cfc -->
	<mx:RemoteObject id="agency" destination="ColdFusion" showBusyCursor="true" source="Media.components.Agency2">
		<mx:method name="getagencyData" result="getagencyData(event)" />
	</mx:RemoteObject>
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.collections.ArrayCollection;
			import mx.utils.StringUtil;
			
			[Bindable] private var gridData:ArrayCollection;
			[Bindable] private var cbData:Array;
			[Bindable] private var agencyData:Array;
			
			private function agencyId_labelFunc(item:Object):String {
                return StringUtil.substitute("{0} ({1})", item.@agencyId, item.@agency);
            }
 
			//on init, populate grid and combo boxes!
			private function init():void{
				ro.getData();
				ro.getcbData();
				agency.getagencyData();
			}
			
			private var isNew:Boolean = true;
			
			public function getDataResult(e:ResultEvent):void{
				dg.dataProvider = e.result as ArrayCollection;
				makeNew();
			}
			
			private function getCBData(e:ResultEvent):void{
				cbData = e.result as Array;
			}
			
			private function getagencyData(e:ResultEvent):void{
				agencyData = e.result as Array;
			}
			
			private function makeNew():void{
				firstNameFld.text = "";
				lastNameFld.text = "";
				officePhoneFld.text = "";
				agencyId.text = "";
				isNew = true;
			}
			private function save():void{
				if(isNew){
					ro.saveNewData(firstNameFld.text,lastNameFld.text,officePhoneFld.text,agencyId.text);
				}else{
					ro.saveOldData(firstNameFld.text,lastNameFld.text,officePhoneFld.text,agencyId.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 dataProvider="{gridData}" 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">
			
			<!-- fill with first names -->
			<mx:FormItem label="First Name" id="firstnameLbl" x="10" y="70" width="266">
				<ns1:comboBox id="firstNameFld" x="106" y="126"  dataProvider="{cbData}" selectedValue="{dg.selectedItem.firstNameFld}"/>
			</mx:FormItem>
			
			<!-- fill with agency names -->
			<mx:FormItem label="agency" id="agencyLbl" x="305" y="70" width="266">
				<ns1:comboBox id="agencyId" x="106" y="126"  dataProvider="{agencyData}" labelFunction="agencyId_labelFunc" selectedValue="{dg.selectedItem.agencyId}"/>
			</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="305" y="40" width="266">
				<mx:TextInput id="officePhoneFld" text="{dg.selectedItem.officePhoneFld}" width="176"/>
			</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
zzynxSr. Software engineerCommented:
>> private function agencyId_labelFunc(item:Object):String {
>>     return StringUtil.substitute("{0} ({1})", item.@agencyId, item.@agency);
>> }
Well, it's not that easy.
To make the above work, your combo box has to contain objects that has both the "agencyId" and "agency" properties.
Which apparently isn't the case currently. (it just contains String's)
Hence the error.

What I suggested was, that your combo should contain agencyId's (again) - because needed for the update.
Then if you have a dictionary/map to translate an id to the agency name you could use that in your  label function. (input:agency id - output:agency name)
0
COwebmasterAuthor Commented:
Ok, that makes sense.  So how would I bring both values into the combo box using the following?
<cfcomponent output="false">
	
	<!--- get agencies; populate combo box --->
	<cffunction name="getAgencyData" access="remote" returntype="array">
		<cfset local = {} />
		
		<cfquery datasource="media" name="local.q">
			select		*
			from		agency
		</cfquery>
		
		<cfset local.result = arrayNew(1) />
		
		<cfloop query="local.q">
			<cfset local.temp = {} />
			<cfset local.temp['data'] = local.q.agencyId />
			<cfset local.temp['label'] = local.q.agency />
			<cfset arrayAppend(local.result,local.temp) />
		</cfloop>
		
		<cfreturn local.result />
	</cffunction>
	
</cfcomponent>

Open in new window

0
zzynxSr. Software engineerCommented:
Could you try if this works:

private function agencyId_labelFunc(item:Object):String {
   return StringUtil.substitute("{0} ({1})", item.@data, item.@label);
}

and if not try this:

private function agencyId_labelFunc(item:Object):String {
  return item.toString();
}

and tell me what the items in your combo box look like.

I almost have to go offline...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zzynxSr. Software engineerCommented:
Going off line now. See you...
0
COwebmasterAuthor Commented:
Ok, the top didn't work, got an error:

Error #1081: Property @data not found on Object and there is no default value

i tried the bottom and it loaded fine but the combo box now has [object] [object] in it
0
zzynxSr. Software engineerCommented:
So, one combo box item now displays as

[object] [object]

?

One toString() call resulting in [object][object].
That would mean that the item coming in (in agencyId_labelFunc) is an array (of 2 objects in this case)

In that case, try applying this agencyId_labelFunc function

private function agencyId_labelFunc(item:Object):String {
    var classInfo:XML = describeType(item);
    return classInfo.@name.toString();
}

and let me know what you see in your combo box for each element. (I expect you see something that contains "Array")
If that is the case change the method like this:

private function agencyId_labelFunc(item:Object):String {
    var classInfo:XML = describeType(Array(item)[0]);
    return classInfo.@name.toString();
}

and again let me know what you see in your combo box for each element.
0
COwebmasterAuthor Commented:
ok, I'll check it out.
0
COwebmasterAuthor Commented:
Thx!
0
zzynxSr. Software engineerCommented:
thanx 4 axxepting
0
COwebmasterAuthor Commented:
sorry it took so long.  I'll manage those better in the future.
0
zzynxSr. Software engineerCommented:
All right :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.