简体   繁体   English

如何在Flex中用行中的不同值类型创建DataGrid?

[英]How to create DataGrid in Flex with different value types in rows?

I want to create the DataGrid like that: 我想像这样创建DataGrid:

{Label} {TextInput}

{Label} {ComboBox}

I can use "ComboBoxGridItemEditor" and etc but problem is that ItemEditors and renderers apllies to the whole column. 我可以使用“ ComboBoxGridItemEditor”等,但是问题是ItemEditor和渲染器适用于整个列。 But I need different types of controls in the different rows but in the same columns. 但是我需要在不同的行中但在同一列中使用不同类型的控件。

For better understanding I did screenshot from VS for example: 为了更好地理解,我从VS截取了屏幕截图,例如:

http://i.stack.imgur.com/ZaAAg.jpg

I want to create properties table like that by MXML because I want to make easier future editing of this table. 我想通过MXML创建属性表,因为我想使以后对该表的编辑更加容易。

Have someone similar task or any ideas how to do that? 是否有类似的任务或任何想法该怎么做? Thanks. 谢谢。

You can define a factory function to create itemRenderers depending on data for a given row. 您可以定义一个工厂函数来根据给定行的数据创建itemRenderer。 Take a look at itemRendererFunction . 看一下itemRendererFunction

Example from 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;
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM