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 Answer 1

3

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}"/> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.