views:

354

answers:

0

I'm trying to add an Image to a datagrid row, but I cant get anything to show.

I'm datagrid dataprovider is an xml file. If tried incorporating the item render inline as will as definining it in another file, and still now joy.

<mx:DataGrid id="nodeGrid" dataProvider="{nodes}" 
    creationComplete="datagridChange()"  dataChange="datagridChange()" 
    height="100%" width="100%" showHeaders="false" rowHeight="20"
    borderThickness="0" horizontalScrollPolicy="off" verticalScrollPolicy="off"
    dragEnabled="true" dragDrop="positionNode(nodeGrid.selectedItem)" 
    doubleClickEnabled="true" doubleClick="doubleClickHandler(nodeGrid.selectedItem)">

    <mx:columns>
        <mx:DataGridColumn  dataField="name"/> <!--itemRenderer="customComponents.ImageRenderer" -->
    </mx:columns>

    <mx:itemRenderer>
        <mx:Component>
          <mx:HBox horizontalGap="2">
            <mx:Script>
                <![CDATA[
                    import mx.controls.Alert;
                    override public function set data(value:Object):void {
                             /* [Embed("/../assets/images/null_node.png")]
                              var helpIcon:Class; */

                            super.data = value;
                            nodeImage.load("/../assets/images/null_node.png");
                    }
                ]]>
            </mx:Script>
            <mx:Image  source="@Embed(source='/../assets/images/null_node.png')" id="nodeImage" height="20" width="20"/>
            <mx:Label text="{data.name}" />
          </mx:HBox>
        </mx:Component>
      </mx:itemRenderer>

</mx:DataGrid>

This is an excerpt from the XML file:

    <node>
        <name>Sink Node</name>
        <icon>/../assets/images/null_node.png</icon>
        <properties>
            <type>Sink</type>
            <defaultName>aSink</defaultName>
            <name>aSink</name>
            <linkType>Link</linkType>
        </properties>
    </node>

If i say nodeImage.load(helpIcon), the icon show up on the grid, but trying to load the actual URL gives me nothing. The URL is what is stored in data.icon. Basically there is a different Icon for each row and that value is stored in the data grid.

I'm wondering if I'm missing something in the rendering step. Any help would be appreciated.