Flex DataGrid 在 DataGridColumn 上具有可变自定义 itemEditor
是否有办法根据 dataField 值创建自定义项目编辑器?例如:
<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}];
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}];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我过去通过创建一个包含所有三个控件的自定义渲染器来处理此问题,并通过在渲染器上设置数据时检查数据类型来确定哪一个是可见的。您可以通过重写 set data 方法并相应地设置三个控件上的visible 和includeInLayout 属性来完成此操作。希望有帮助。
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.
有点晚了答案...您可以使用 ClassFactory。 Farata Systems 已发表博客(http://flexblog.faratasystems.com/2006 /09/26/ditemrenderers-vs-itemeditors)对此以及他们的书中有更详细的解释。
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.