Hello helpful people! :)

I have a datagrid that is populated by an external XML file.  Some of
the cells have various icons in them.  I am using an itemRenderer to
insert an image in the first column.  However, I do not know how to
use this same itemRenderer/component for the other images, because the
component currently has the dataField "hardcoded".  I need a way to
re-use this itemRenderer/component so that whatever dataField if being
used passes itself to the component dynamically.

This sounds confusing, but it isn't.  Here are the two important snips
of code:

FROM mainmxml 
--------------
<mx:DataGrid....>
<mx:columns>
<mx:DataGridColumn headerText="Image 1" dataField="f3"
itemRenderer="IconRenderer"/>
<mx:DataGridColumn headerText="Color 2" dataField="f5"/>
<mx:DataGridColumn headerText="Properties 3" dataField="f6"/>
<!-- I need another DataGridColumn here with dataField="f7" that ALSO
uses itemRenderer="IconRenderer" -->
</mx:columns> 
</mx:DataGrid>

FROM IconRenderer.mxml
----------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; 
horizontalAlign="center" verticalAlign="middle"
width="16" height="16">
<!-- I want to pass an argument to the "data.f3" below, because this
     component might use f3, f7, or f-something else, too -->
<mx:Image source="{'images/icon_' + data.f3 + '.gif'}"/>
</mx:VBox>

I am sure there is an easy way to make a function here, but I just
don't know how.

Thanks,
Ann

Reply via email to