views:

1102

answers:

1

Hello, I'm trying to put some File objects into a DataGrid, but I can't find a way to display the File.icon in there.

So far I have this: (ms[x] is a File)

listData.addItem({
 filename:ms[x].nativePath.replace(/.*\\/,""),
 path:ms[x].nativePath.replace(/\\[^\\]*$/,"\\"),
 icon:ms[x].icon.bitmaps[0]
});

and

<mx:DataGrid x="358" y="0" width="429" height="378" dataProvider="{listData}">
 <mx:columns>
  <mx:DataGridColumn headerText="Column 1" dataField="filename"/>
  <mx:DataGridColumn headerText="Column 2" dataField="icon">
   <mx:itemRenderer>
    <fx:Component>
     <mx:Image width="32" height="32" source="{data}">
     </mx:Image>
    </fx:Component>
   </mx:itemRenderer>
   </mx:DataGridColumn>
  <mx:DataGridColumn headerText="Column 3" dataField="path"/>
 </mx:columns>
</mx:DataGrid>

filename and path are displayed correctly, I just can't get the file icon to show.

How can I do that ?

A: 

The source of the image needs to be the path to the file and right now your sending it the whole data object. Assuming data.path contains the full path including the filename you would type:

 <mx:Image width="32" height="32" source="{data.path}">
greg
thats the thing... File.icon is not a filename, its an Icon object containing .bitmaps array. these are not real files on filesystem, so I need to display the bitmap, not an actual image file.
jab11