【问题标题】:How to create DataGrid in Flex with different value types in rows?如何在 Flex 中创建具有不同值类型的行中的 DataGrid?
【发布时间】:2014-11-26 15:24:07
【问题描述】:
我想像这样创建 DataGrid:
{Label} {TextInput}
{Label} {ComboBox}
我可以使用“ComboBoxGridItemEditor”等,但问题是 ItemEditors 和渲染器适用于整个列。但是我需要在不同的行但在相同的列中使用不同类型的控件。
为了更好地理解,我做了 VS 的截图,例如:
我想通过 MXML 创建类似的属性表,因为我想让以后编辑这个表更容易。
有类似的任务或任何想法如何做到这一点?
谢谢。
【问题讨论】:
标签:
apache-flex
datagrid
mxml
flex-spark
【解决方案1】:
您可以定义工厂函数来根据给定行的数据创建 itemRenderer。看看itemRendererFunction。
来自here的示例:
private function selectRenderer(item:Object):ClassFactory {
var classFactory:ClassFactory;
if(item is IVisualElement){
// If the item is a Flex component, use DefaultComplexItemRenderer.
classFactory = new ClassFactory(DefaultComplexItemRenderer);
}
else if (item is Object){
// If the item is an Object, use MySimpleItemRendererFunction.
classFactory = new ClassFactory(MySimpleItemRendererEmployee);
}
return classFactory;
}