HI , I am new to this discussion forum and i am not sure the process of posting here. Excuse me if there is anything wrong from my side.
I have recently started to work on flex and i am seeing some strange behavior with the combo box in the grid. Here is the code i have used to test my work: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.DataGridEvent; import mx.collections.ArrayCollection; import mx.controls.TextInput; public var newCity:String; public var newState:String; [Bindable] public var cpirDG:ArrayCollection = new ArrayCollection([ {lobPrintName: 'Name1' , noLobContract: true , lobOpenPractice: '1'}, {lobPrintName: 'Name2' , noLobContract: false , lobOpenPractice: '2'}, ]); [Bindable] public var openPracticeData:ArrayCollection = new ArrayCollection([ '1', '2', '3' ]); public function update():void { Alert.show("inside update"); cpirDG = new ArrayCollection([ {lobPrintName: 'Name1' , noLobContract: true , lobOpenPractice: '1'}, {lobPrintName: 'Name2' , noLobContract: true , lobOpenPractice: '2'}, ]); cpirDG.refresh(); } ]]> </mx:Script> <mx:Canvas width="100%" height="100%" id="cpirLobExceptios"> <mx:VBox width="100%" height="100%"> <mx:DataGrid width="100%" height="70%" id="cpirID" dataProvider="{cpirDG}" > <mx:columns> <mx:DataGridColumn headerText="Line Of Business" dataField="lobPrintName"/> <mx:DataGridColumn dataField="noLobContract" > <mx:itemRenderer > <mx:Component> <mx:CheckBox selected="{data.noLobContract}"/ > </ mx:Component> </mx:itemRenderer> </mx:DataGridColumn> <mx:DataGridColumn width="600" headerText="Open Practice" dataField="lobOpenPractice" rendererIsEditor="true"> <mx:itemRenderer> <mx:Component className="editor"> <mx:VBox> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.collections.ArrayCollection; private function getOpenPracticeData():void { for (var i:int=0;i<test.dataProvider.length;i++){ var item:String = test.dataProvider[i]; if (data.lobOpenPractice != null) { if(item == data.lobOpenPractice){ test.selectedIndex = i; break; } } else { break; } } } ]]> </mx:Script> <mx:ComboBox change="data.lobOpenPractice = test.selectedItem" creationComplete="getOpenPracticeData()" id="test" dataProvider="{outerDocument.openPracticeData}" prompt="Select the appropriate Open Practice" /> <mx:Button click="test.selectedIndex = -1" label="Clear" id="clear"/> </mx:VBox> </ mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <mx:Button id="save" label="Save" name="save" click="update()" /> </mx:VBox> </mx:Canvas> </mx:Application> If we execute this code in flex builder, we will see a grid with a text field, check box and combo box, in the update function i am changing the data provider for the grid, i have changed the check box value to true for the second entry in the grid, when i click save button the check box is updated correctly but if u have observed the combox values have changed. Initially the values in the combo box selected are 1 and 2, once i click save, it changes to 1 and 1, then if i click save again i changes to 2 and 1, again if i do it, it changes to 1 and 2. Can anyone please let me know why this happens. And how can i have the values consistent. Thankyou in advance. Regards, Kranthi. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

