views:

56

answers:

2

Is there anyway to create a custom item editor based on the dataField value? For example:

<mx:DataGrid editable="true" dataProvider="{_actionArr}" id="prop">  
  <mx:column>
    <mx:DataGridColumn headerText="Component" editable="false" dataField="label"/>
    <mx:DataGridColumn headerText="Value" editable="true" itemEditor="{data.ie}"/>
  </mx:columns> 
</mx:DataGrid>

...

[Bindable] private var _actionArr:Array = [   
{ label:"Slider", val:"", ie:mx.controls.HSlider },   
{ label:"ComboBox", val:"", ie:mx.controls.ComboBox  },   
{ label:"Button", val:"", ie:mx.controls.Button}];
+1  A: 

I've handled this in the past by creating a custom renderer that contains all three controls and determining which one is visible by checking the data type when the data gets set on the renderer. You do this by overriding the set data method and setting the visible and includeInLayout properties on the three controls accordingly. Hope that helps.

Wade Mueller
Yea, that's what I'm doing now. I thought there might be a more flex-ish idiom to do it.
rforte
A: 

A tad late answer... You can use ClassFactory. Farata Systems has blogged(http://flexblog.faratasystems.com/2006/09/26/ditemrenderers-vs-itemeditors) on this and a more detailed explanation in their book.

Ole Christian Langfjæran