I managed to implemented the functionality by listening for
itemEditBeginning events:
I mananged got hold of my current row in my dataprovider by calling:
var row : XML =
event.currentTarget.dataProvider.getItemAt(event.rowIndex);
By acessing the current row I could determine if the current cell was
allowed to be edited. If not changed the editedItemPosition on my grid
and prevented the default behavior:
event.currentTarget.editedItemPosition = {columnIndex:
alternativeColumn,rowIndex: event.rowIndex};
event.preventDefault();
--- In [email protected], "jacobvoneyben" <[EMAIL PROTECTED]>
wrote:
>
> I would like to dynamically set the editable property for a cells in a
> datagrid depending on data in my dataprovider, but I don't see any
> easy way to accomplish this with the DataGrid as it is.
>
> Example:
>
> My databinded xml dataprovider structure looks like this:
>
> persons
> person
> @editableFirstname (attribute)
> @editableLastname (attribute)
> firstname
> lastname
>
> I have looked a bit into the source for the DataGrid and
> DataGridColumn. The editable property seems to be static and set for
> the entire column (not just a cell) does anyone have any idea of how I
> can set a single cell to editable?
>
> Ideally it should be possible to write something like this:
> <mx:DataGrid dataprovider="{myDatagrid}"...>
> <mx:columns>
> <mx:DataGridColumn dataField="firstname"
> editable="@editableFirstname">
> ...
> <mx:columns>
> </mx:DataGrid>
> Where the editableFirstname is dynamically looked up in the
> dataprovider the sameway as the datafield is.
>
> Regards
> Jacob von Eyben
> http://ancientprogramming.blogspot.org
>