Is what you're trying to do similar to what the Change button does in the example app below? If it is but you still can't get your app to work, maybe there's a mismatch with the data somewhere (I know this is the case in the example, which is why the button is able to reset the combobox value, but a selection made directly from the combobox won't stick).
- Doug Example app: ------------ <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" width="100%" height="100%"> <mx:Script> <![CDATA[ var aryLoc: Array = [{state: "CA"}, {state: "CO"}, {state: "CT"}]; function updateStateCbx(): Void { dgLocationInfo.dataProvider.editField (2, "state", "WA"); } ]]> </mx:Script> <mx:DataGrid id="dgLocationInfo" width="90%" editable="true" dataProvider="{aryLoc}" rowCount="5"> <mx:columns> <mx:Array> <mx:DataGridColumn headerText="State" columnName="LocState" editable="false" cellRenderer="StateRenderer" width="120"/> </mx:Array> </mx:columns> </mx:DataGrid> <mx:Button label="Change ''CT'' to ''WA''" click="updateStateCbx ()"/> </mx:Application> ----------------------------------------------- --- In [email protected], "mrvinedit" <[EMAIL PROTECTED]> wrote: > > Thanks Doug, but for some reason that's not working for me. > > --- In [email protected], "Doug Lowder" <douglowder@> wrote: > > > > Hi, > > > > In function updateStateCbx(), try calling the following: > > dgLocationInfo.dataProvider.editField(selIdx, "data", selState). > > The grid should notice the change to the dataprovider and cause your > > cell renderer to automatically update the combobox. > > > > Regards, > > Doug > > > > > > --- In [email protected], "mrvinedit" <owner@> wrote: > > > > > > I'm passing in selIdx and selState variables from another mxml not > > > shown here, but suffice to say my alert is showing the correct data > > > for the index of the state and the state's data. For some reason > > (must > > > be my code :-) the datagrid-embedded combobox is not changing the > > > state that's coming in from my data. Suggestions? > > > > > > Grid.mxml: > > > > > > <mx:Script> > > > <![CDATA[ > > > function updateStateCbx(selIdx,selState): { > > > mx.controls.Alert.show(selIdx + ': ' + selState); > > > dgLocationInfo.selectedItem.LocState.editField (selIdx, "data", > > > selState); > > > } > > > ]]> > > > </mx:Script> > > > > > > <mx:DataGrid id="dgLocationInfo" width="90%" editable="true" > > > dataProvider="{aryLoc}" rowCount="5" > > > change="updateGridRowModel > > (dgLocationInfo.selectedItem.LocNum,dgLocationInfo.selectedItem.LocAd > > dr,dgLocationInfo.selectedItem.LocZip,dgLocationInfo.selectedItem.Loc > > City,dgLocationInfo.selectedItem.LocState)"> > > > <mx:columns> > > > <mx:Array> > > > <mx:DataGridColumn headerText="State" columnName="LocState" > > > editable="false" cellRenderer="StateRenderer" width="120"/> > > > </mx:Array> > > > </mx:DataGrid> > > > > > > StateRenderer: > > > > > > import mx.controls.ComboBox; > > > > > > class StateRenderer extends mx.core.UIComponent { > > > > > > var comboDP:Array = [{label:"Alabama", data:"AL"}, > > {label:"Alaska", > > > data:"AK"}, {label:"Arizona", data:"AZ"}, {label:"Arkansas", > > > data:"AR"}, {label:"California", data:"CA"}, {label:"Colorado", > > > data:"CO"}, {label:"Connecticut", data:"CT"}, {label:"Delaware", > > > data:"DE"}, {label:"Florida", data:"FL"}, {label:"Georgia", > > > data:"GA"}, {label:"Hawaii", data:"HI"}, {label:"Idaho", > > data:"ID"}, > > > {label:"Illinois", data:"IL"}, {label:"Indiana", data:"IN"}, > > > {label:"Iowa", data:"IA"}, {label:"Kansas", data:"KS"}, > > > {label:"Kentucky", data:"KY"}, {label:"Louisiana", data:"LA"}, > > > {label:"Maine", data:"ME"}, {label:"Maryland", data:"MD"}, > > > {label:"Massachusetts", data:"MA"}, {label:"Michigan", data:"MI"}, > > > {label:"Minnesota", data:"MN"}, {label:"Mississippi", data:"MS"}, > > > {label:"Missouri", data:"MO"}, {label:"Montana", data:"MT"}, > > > {label:"Nebraska", data:"NE"}, {label:"Nevada", data:"NV"}, > > > {label:"New Hampshire", data:"NH"}, {label:"New Jersey", > > data:"NJ"}, > > > {label:"New Mexico", data:"NM"}, {label:"New York", data:"NY"}, > > > {label:"North Carolina", data:"NC"}, {label:"North Dakota", > > > data:"ND"}, {label:"Ohio", data:"OH"}, {label:"Oklahoma", > > data:"OK"}, > > > {label:"Oregon", data:"OR"}, {label:"Pennsylvania", data:"PA"}, > > > {label:"Rhode Island", data:"RI"}, {label:"South Carolina", > > > data:"SC"}, {label:"South Dakota", data:"SD"}, {label:"Tennessee", > > > data:"TN"}, {label:"Texas", data:"TX"}, {label:"Utah", data:"UT"}, > > > {label:"Vermont", data:"VT"}, {label:"Virginia", data:"VA"}, > > > {label:"Washington", data:"WA"} ]; > > > var combo; > > > var listOwner : MovieClip; > > > var getCellIndex : Function; > > > var getDataLabel : Function; > > > > > > function createChildren(Void) : Void { > > > combo = createClassObject( ComboBox, "combo", 1, > > {owner:this, _x:1}); > > > combo.dataProvider = comboDP; > > > combo.addEventListener("change", this); > > > } > > > > > > function getPreferredHeight(Void) : Number{ > > > return combo != undefined ? 18:0; > > > } > > > > > > function getPreferredWidth(Void) : Number{ > > > return combo != undefined ? 100:0; > > > } > > > > > > function setValue(str:String, item:Object) { > > > var val = item.state; > > > for(var i = 0; i < combo.dataProvider.length; i++) { > > > combo.dataProvider[i].data == val ? > > combo.selectedIndex = i : ''; > > > } > > > } > > > > > > function change() { > > > listOwner.editField(getCellIndex().itemIndex, > > getDataLabel(), > > > combo.selectedItem.data); > > > listOwner.selectedIndex = getCellIndex().itemIndex; > > > } > > > } > > > > > > -- 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/

