spotted a few problem with your example. 1) not sure if your event.columnIndex == 1 is correct. 2) backgroundColor is a style not a property, so you cant set it like that in your itemEditBegin handler.
if all your trying to do is change the backgroundColor of the itemEditorInstance, then do it in the itemFocusIn handler public function itemFocusInHandler():void { textinput:TextInput = dg.itemEditorInstance as TextInput; textinput.setStyle("backgroundColor", "red"); } --- In flexcoders@yahoogroups.com, "Ghose, Sanjucta" <[EMAIL PROTECTED]> wrote: > > > I am trying to handle the itemEditBegin event to dynamically change the > item editor for a particular datagrid cell. > > > > The following code should produce an itemeditor with background color > red. But this does not appear to work. > > > > event.preventDefault(); > > var xxx:ClassFactory = new ClassFactory(TextInput); > > xxx.properties = {backgroundColor:"red"}; > > contact.itemEditor = xxx; > > dg.createItemEditor(event.columnIndex,event.rowIndex); > > > > The whole code is : > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute" creationComplete="initData()"> > > > > <mx:Script> > > <![CDATA[ > > import mx.controls.CheckBox; > > import mx.controls.Text; > > import mx.controls.TextInput; > > import mx.events.DataGridEvent; > > import mx.collections.ArrayCollection; > > > > private var DGArray:Array = [ > > {contactId:'110011', firstName:'Sanjucta',lastName:'Ghose'}, > > {contactId:'110012', firstName:'Swapnil',lastName:'Ghose'}]; > > > > [Bindable] > > public var initDG:ArrayCollection; > > public function initData():void { > > initDG=new ArrayCollection(DGArray); > > dg.dataProvider = initDG; > > } > > > > > > public function disableEdit(event:DataGridEvent):void { > > > > if(event.columnIndex == 1) > > { > > > > > > event.preventDefault(); > > var xxx:ClassFactory = new ClassFactory(TextInput); > > xxx.properties = {backgroundColor:"red"}; > > contact.itemEditor = xxx; > > dg.createItemEditor(event.columnIndex,event.rowIndex); > > > > } > > } > > > > ]]> > > </mx:Script> > > <mx:DataGrid id="dg" editable="true" > itemEditBegin="disableEdit(event)"> > > <mx:columns> > > <mx:DataGridColumn dataField="contactId" headerText="Id" > editable="false" id="contact" /> > > <mx:DataGridColumn dataField="firstName" headerText="First > Name"/> > > <mx:DataGridColumn dataField="lastName" headerText="Last Name"/> > > </mx:columns> > > > > </mx:DataGrid> > > </mx:Application> > > > > > > > > Thanks & Regards > > > > Sanjucta Ghose| Capgemini | Kolkata, India > > Senior Consultant - CSD > > Direct: +91 33 66102511 > > VOIP:358 > > Mobile:+919830215789 > > Email:[EMAIL PROTECTED] > > Join the Collaborative Business Experience > > visit http://www.in.capgemini.com > > > > > > This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. >