I am adding an image to a cell of datagrid using an item renderer embedded in a data grid column. I need to add an image to a cell only if data from the row of the cell meets certain requirements. something like below is what I am trying to achieve:
<mx:AdvancedDataGridColumn dataField="delete" headerText="Delete" >
<mx:itemRenderer>
<mx:Component>
<mx:VBox horizontalAlign="center" verticalAlign="middle">
<mx:Script>
<![CDATA[
public function showImage():void{
if(rowData.column1 == "image1"){
image1.visible = true;
}
else{
image1.visible = false;
}
]]>
</mx:Script>
<mx:Image source="{image1}" visible="{showImage}" id="deleteFile" click="" scaleX="0.1" scaleY="0.1" horizontalCenter="true" horizontalAlign="center"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
Add the following code to <mx:Script>
override public function set data(value:Object):void
{
super.data = value;
showImage();
}
set data
is the function that the grid
calls to do set up, this is the best function to override to apply conditional properties to the ItemRenderer