And here is an enhanced example that has both the same structure and different structures. Tracy <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" initialize="initApp()" horizontalAlign="left"> <mx:Script><![CDATA[ public var aDP:Array = [ {label:"A", Number:0}, {label:"B", Number:1}, {label:"C", Number:2}]; private function initApp():Void { } private function addRow():Void{ dgTarget.addItem( cboSource.selectedItem ); } private function addRow2():Void{ var sLabel:String = cboSource2.selectedItem.label; var nNumber:Number = cboSource2.selectedItem.Number; dgTarget2.addItem( {someOtherlabel:sLabel, someOtherNumber:nNumber} ); } ]]></mx:Script> <mx:Label text="This example has the same item object structure for both controls" /> <mx:HBox> <mx:ComboBox id="cboSource" dataProvider="{aDP}" width="150" /> <mx:Button label="Add Selected Item to DataGrid" click="addRow()"/> <mx:DataGrid id="dgTarget"> <mx:columns> <mx:Array> <mx:DataGridColumn headerText="Label" columnName="label" /> <mx:DataGridColumn headerText="Number" columnName="Number" /> </mx:Array> </mx:columns> </mx:DataGrid> </mx:HBox> <mx:Label text="This example has different item object structures" /> <mx:HBox> <mx:ComboBox id="cboSource2" dataProvider="{aDP}" width="150" /> <mx:Button label="Add Selected Item to DataGrid" click="addRow2()"/> <mx:DataGrid id="dgTarget2"> <mx:columns> <mx:Array> <mx:DataGridColumn headerText="Label" columnName="someOtherlabel" /> <mx:DataGridColumn headerText="Number" columnName="someOtherNumber" /> </mx:Array> </mx:columns> </mx:DataGrid> </mx:HBox>
</mx:Application> -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Spratt Sent: Wednesday, March 29, 2006 8:32 PM To: [email protected] Subject: RE: [flexcoders] Re: databinding issue for combobox Here is a sample app that migh approach what you want. It assumes the item object structures are the same for both controls. Tracy <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" horizontalAlign="left"> <mx:Script><![CDATA[ public var aDP:Array = [ {label:"A", Number:0}, {label:"B", Number:1}, {label:"C", Number:2}]; private function addRow():Void{ dgTarget.addItem( cboSource.selectedItem ); } ]]></mx:Script> <mx:HBox> <mx:ComboBox id="cboSource" dataProvider="{aDP}" width="150" /> <mx:Button label="Add Selected Item to DataGrid" click="addRow()"/> <mx:DataGrid id="dgTarget"> <mx:columns> <mx:Array> <mx:DataGridColumn headerText="Label" columnName="label" /> <mx:DataGridColumn headerText="Number" columnName="Number" /> </mx:Array> </mx:columns> </mx:DataGrid> </mx:HBox> -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Spratt Sent: Wednesday, March 29, 2006 7:16 PM To: [email protected] Subject: RE: [flexcoders] Re: databinding issue for combobox Item objects(rows) contain multiple properties(columns). Is the structure of the item object the same for the combobox dataProvider and the DataGrid dataProvider? If so you should be able to simply specify the combobox selectedItem as the argument to addItem. Maybe you have to cast the selectedItem as Object? If the two item objects are not the same structure then you are on the right track, but you want to put the property balue in the new property, not the whole item object. Maybe: dgResources.addItem( {dept: cmbDept.selectedItem.dept} ); I'll see if I can do a quick example, and see what works. Tracy -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of rgwilson26 Sent: Wednesday, March 29, 2006 4:35 PM To: [email protected] Subject: [flexcoders] Re: databinding issue for combobox I actually have multiple columns in my dg which is why I am using dgResources.addItem( {dept: cmbDept.selectedItem} ); I cut down the example for simplicity. However, I did try the example you suggested and it gives me a statement incomplete error. I think it needs a identifier for each specific column. Would I have to somehow loop through the new object in the combo box and pull each specific item out? --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > When you do this: > dgResources.addItem( {dept: cmbDept.selectedItem} ); } > > you are putting the whole combobox item object into the dept property of > a new object. > > Perhaps you just want: > dgResources.addItem(cmbDept.selectedItem); > > Tracy > > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of rgwilson26 > Sent: Wednesday, March 29, 2006 10:16 AM > To: [email protected] > Subject: [flexcoders] Re: databinding issue for combobox > > Basically I am calling a query that will populate a combobox. Then > the user will be able to use a click event that will send that value > from the combo box to a datagrid. Right now it sends a value from the > combobox to the datagrid, but what is displayed is [object Object] > instead of the desired value. > > Here is an example: > > <SCRIPT> > public var dp:Array; > > private function addRow():Void{ > dgResources.addItem( {dept: cmbDept.selectedItem} ); > } > > private function doResult(result:Array):Void { > dp = result; > } > > <SCRIPT> > > <mx:RemoteObject id="ro" > endpoint="http://10.95.20.39:8500/flashservices/gateway" > source="cfdocs.components.getPersonnel"> > <mx:method name="serviceDeptLOV" result="doResult > (event.result._items)"/> > > </mx:RemoteObject> > > > > <mx:DataGrid id="dgResources"> > <mx:column> > <mx:Array> > <mx:DataGridColumn headerText="Department" columnName="dept" > width="200" /> > </mx:Array> > </mx:columns> > </mx:DataGrid> > > <mx:ComboBox id="cmbDept" dataProvider="{dp}"/> > > <mx:Button label="Add" click="{addRow()}" textAlign="center" > width="75"/> > > > > ******CFC Query******** > > <cffunction name="serviceDeptLOV" access="remote" returntype="query"> > <cfquery name="getserviceDept" datasource="spotDB"> > SELECT ServiceDept > FROM dbo.ServiceDeptLOV > ORDER BY ServiceDept > </cfquery> > > > <cfreturn getserviceDept> > </cffunction> > > > --- In [email protected], "Tracy Spratt" <tspratt@> wrote: > > > > [object Object] means you are trying to display a complex object as > > text. > > > > Can you be more specific about what you mean when you say " send the > > results from the combobox to a datagrid "? > > > > Tracy > > > > -----Original Message----- > > From: [email protected] > [mailto:[EMAIL PROTECTED] On > > Behalf Of rgwilson26 > > Sent: Tuesday, March 28, 2006 2:41 PM > > To: [email protected] > > Subject: [flexcoders] databinding issue for combobox > > > > I am working on an app where I am populating various combo boxes > with > > results from my look up tables in a sql server database. I have no > > problem binding the results to the comboboxes dataProvider > property. > > However, when I try to send the results from the combobox to a > datagrid > > it populates the datagrid field with [object Object] instead of the > > selected item value. > > > > I can call a query and populate a datagrid directly and it doesn't > seem > > to be an issue, so I am a little confused as to why it is a problem > > going from a combobox to a datagrid? > > > > Any suggestions? > > > > > > > > > > > > > > > > -- > > Flexcoders Mailing List > > FAQ: > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > Search Archives: > > http://www.mail-archive.com/flexcoders%40yahoogroups.com > > Yahoo! Groups Links > > > > > > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

