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

84 Views Asked by At

I want to create the DataGrid like that:

{Label} {TextInput}

{Label} {ComboBox}

I can use "ComboBoxGridItemEditor" and etc but problem is that ItemEditors and renderers apllies to the whole column. 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:

https://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.

Have someone similar task or any ideas how to do that? Thanks.

1

There are 1 best solutions below

0
kjokinen On BEST ANSWER

You can define a factory function to create itemRenderers depending on data for a given row. Take a look at 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;
}