I am trying to validate the data entered in a datagrid cell that uses
custom item renderers and editors.I noticed that if I use a custom item
renderer the DataGridEvent.reason is not set properly on the itemEditEnd
event. 

For example, I have a datagrid with 2 columns A  & B. Column B has a
custom renderer. If I try to handle the itemEditEnd event when the user
finishes editing column A by clicking on column B then the event.reason
that is set on the DataGridEvent  is DataGridEventReason.OTHER instead
of DataGridEventReason.NEW_COLUMN as expected.

 

If you click on 'Artist' after editing the 'Album' field the event shows
as newColumn but if you click on 'Price' the event shows as Other.

 

Source Code:

 

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 

   initialize="initData()">

   <mx:Script>

   <![CDATA[

      import mx.events.DataGridEventReason;

      import mx.events.DataGridEvent;

      import mx.controls.TextInput;

      import mx.collections.*;

      private var DGArray:Array = [

         {Artist:'Pavement', Album:'Slanted and Enchanted',
Price:11.99},

         {Artist:'Pavement', Album:'Brighten the Corners',
Price:11.99}];

         

      [Bindable]

      public var initDG:ArrayCollection;

      //Initialize initDG ArrayCollection variable from the Array.

      //You can use this technique to convert an HTTPService, 

      //WebService, or RemoteObject result to ArrayCollection.

      public function initData():void {

         initDG=new ArrayCollection(DGArray);

      }

      

      public function endEditing(event:DataGridEvent):void {

         if(event.columnIndex==0)

         {

            

            lab.text = event.reason;

            

         }

      }

   ]]>

   </mx:Script>

 

   <mx:DataGrid id="myGrid" width="350" height="200" 

      dataProvider="{initDG}"  itemEditEnd="endEditing(event)"
editable="true"  >

      <mx:columns>

         <mx:DataGridColumn dataField="Album"   editable="true"/>

         <mx:DataGridColumn dataField="Artist"   editable="true"/>

         <mx:DataGridColumn dataField="Price" editable="true"
itemRenderer="mx.controls.TextInput"/>

      </mx:columns> 

   </mx:DataGrid>

   <mx:Label id="lab"/>

</mx:Application>

 



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