views:

91

answers:

1

How do i add a image to a column in the datagrid?

Currently my code is

<mx:DataGridColumn dataField="image" headerText="Photo Image" editable="false">
                <mx:itemRenderer>
                    <mx:Component>
                    <mx:HBox height="30" horizontalAlign="center">
                        <mx:Image source="{'assets/image.jpg'}"/>
                    </mx:HBox>
                    </mx:Component>
                </mx:itemRenderer>
</mx:DataGridColumn>

WGere the dataField = "image" is the name of the picture file.

+1  A: 

See below... assuming "image" only has the filename, and not the path of "assets/"

<mx:DataGridColumn dataField="image" headerText="Photo Image" editable="false"> 
                <mx:itemRenderer> 
                    <mx:Component> 
                    <mx:HBox height="30" horizontalAlign="center"> 
                        <mx:Image source="{'assets/' + data.image}"/> 
                    </mx:HBox> 
                    </mx:Component> 
                </mx:itemRenderer> 
</mx:DataGridColumn> 

If the full path to the image is indeed stored in "image", then use this

<mx:Image source="{data.image}"/> 
Chris Klepeis