If you have a data field that specifies data type
then you could use
<mx:Image source="icon_{data.type}.gif" />
Vinoth Babu wrote:
> Below code loads single image in a column, but i need to load different
> images according to the data provided in 'img' xml attribute
> for e.g
> if a img attribute == pdf then load pdf.gif
> else
> if a img attribute == word then load word.gif
> in a column,how to give condition under component
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
> backgroundGradientColors="[#ffffff, #ffffff]">
> <mx:XML id="documentationService" source="documentation.xml" />
> <mx:XMLListCollection id="xc" source="{documentationService.document}"/>
> <mx:DataGrid horizontalCenter="0" borderStyle="solid" width="450"
> height="100%" dataProvider="{xc}">
> <mx:columns>
> <mx:DataGridColumn width="300" headerText="Document Name"
> dataField="@name"/>
> <mx:DataGridColumn width="50" headerText="pdf" >
> <mx:itemRenderer>
> <mx:Component>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
> <mx:Image source="icon_pdf.gif" />
> </mx:HBox>
> </mx:Component>
> </mx:itemRenderer>
> </mx:DataGridColumn>
> </mx:columns>
> </mx:DataGrid>
> </mx:Application>
>
> <!-- document .xml
> <documents>
> <document name="Installing Flex 2"
> html="http://www.adobe.com/support/documentation/en/flex/2/install.html"
> img="word"/>
> <document name="Getting Started with Flex 2"
> html="http://www.adobe.com/go/flex2_gettingstarted" img="pdf" />
> </documents>
> -->
>
>
> Thanks,
> Vinoth
>
> Vinoth Babu <[EMAIL PROTECTED]> wrote:
> Thanks for your info .
>
> But I need to load images according to the data.
>
> for e.g.
>
> In a column , if a data is 'pdf' then load 'pdf.gif' or if it's 'word'
> load 'word.gif'
>
> pdf.gif or word.gif or... are shown in one column in a different row each
>
>
> Thanks ,
> Vinoth
>
> Jack OMelia <[EMAIL PROTECTED]> wrote:
> Try using an itemRenderer.
>
> Create a separate component that looks like this:
> (saved as imageRenderer.mxml in the comps directory)
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
> paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="2"
> width="50" height="20" horizontalAlign="center" >
> <mx:Image source="images/image.gif" width="14" height="14" />
> </mx:HBox>
>
> then add it to your datagrid like this:
>
> <mx:DataGridColumn headerText="!" itemRenderer="comps.imageRenderer" />
>
> HTH, Jack
>
> --- In [email protected], Vinoth Babu <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Need your help to load an different images in a datagrid column
>>
>> Thanks
>> Vinoth
>>
>>
>>
>> ---------------------------------
>> Don't be flakey. Get Yahoo! Mail for Mobile and
>> always stay connected to friends.
>>
>
>
>
>
>
> ---------------------------------
> Never miss an email again!
> Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.
>
>
>
>
> ---------------------------------
> Don't be flakey. Get Yahoo! Mail for Mobile and
> always stay connected to friends.
--
Ben Marchbanks
::: alQemy ::: transforming information into
intelligence
http://www.alQemy.com
::: magazooms ::: digital magazines
http://www.magazooms.com
Greenville, SC
864.284.9918