Search code examples
apache-flexitemrenderer

Flex - Datagrid ItemRenderer


Is it possible to put an itemrenderer on the DataGrid itself rather than a datagridcolumn? I could only find examples for datagridcolumn. I want a generic itemrenderer on all the items in a datagrid...


Solution

  • Yes. (this is a Flex 4 example, but same is true for 3)

    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable] private var dp:ArrayCollection = new ArrayCollection([{far:"test",sight:"test"},{far:"test",sight:"test"},{far:"test",sight:"test"},{far:"test",sight:"test"}]);
            ]]>
        </fx:Script>
        <mx:DataGrid width="100%" height="100%" dataProvider="{dp}">
            <mx:itemRenderer>
                <fx:Component>
                    <mx:Label text="woot there it is"/>
                </fx:Component>
            </mx:itemRenderer>
        </mx:DataGrid>
    </s:Application>
    

    Peter Ent's itemRenderer Series is killer.