Thanks - that worked!!

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Tuesday, May 20, 2008 7:52 AM
To: [email protected]
Subject: RE: [flexcoders] Datagrid cell editing question

 

You'd have to set editedItemPosition

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of pratima_jrao
Sent: Monday, May 19, 2008 5:00 PM
To: [email protected]
Subject: [flexcoders] Datagrid cell editing question

Hi,

I have an application where I prevent users from editing certain cells
in a datagrid. I am using the itemEditBeggining event and when the
event gets triggered I call the event.preventDefault() method if the
cell should not be edited. 

The problem with this approach is that the tab functionality doesn't
work. I am attaching a snippet of code from the adobe site from where
I used this approach. Here is the link too if you want to play with
the example datagrid.
http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_8.htm
l
<http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_8.ht
ml> 

Do you folks have an idea about how to make tab work in the datagrid?
so it skips the cell that shouldn't be edited and jumps to the next
cell that can be edited? Any suggestions or ideas on this will be
highly appreciated.

Thanks,

Pratima

<?xml version="1.0"?>
<!-- itemRenderers\events\EndEditEventPreventEdit.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">

<mx:Script>
<![CDATA[

import mx.events.DataGridEvent;
import mx.collections.ArrayCollection;

[Bindable]
private var initDG:ArrayCollection = new ArrayCollection([
{Artist:'Pavement', Album:'Slanted and Enchanted', 
Price:11.99},
{Artist:'Pavement', Album:'Brighten the Corners', 
Price:11.99}
]);

// Define event listener for the cellEdit event 
// to prohibit editing of the Album column.
private function disableEditing(event:DataGridEvent):void {
if(event.columnIndex==1)
{ 
event.preventDefault(); 
}
} 

]]>
</mx:Script>

<mx:DataGrid id="myGrid" 
dataProvider="{initDG}" 
editable="true" 
itemEditBeginning="disableEditing(event);" > 
<mx:columns>
<mx:DataGridColumn dataField="Artist"/>
<mx:DataGridColumn dataField="Album"/>
<mx:DataGridColumn dataField="Price"/>
</mx:columns> 
</mx:DataGrid> 
</mx:Application>



 

Reply via email to