Hi Sanjucta 

Wouldn't a custom ItemRenderer be more appropriate?

Check out the below link... 

http://weblogs.macromedia.com/pent/archives/2007/02/coloring_the_ba.cfm

Regards

Mark
--- In [email protected], "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.
>


Reply via email to