Flex ~ change DataGridColumn color by itemRenderer

this is an example if the value lower than 5%

change the font to red color

public function setMarginColor(field:String):uint
{
       field = field.slice(0, (field.length - 1));
       var marginPercent:Number = parseFloat(field);
       
       trace(marginPercent);
       if(marginPercent < 5)
       {
        return 0xff0000;
       }
       
       else
       {
        return 0x000000;
       }
}


<mx:DataGridColumn width="80" headerText="Margin%" wordWrap="true" sortable="false" textAlign="right" dataField="MarginPercent" paddingRight="2" >
<mx:itemRenderer>
<mx:Component>
<mx:Label text="{data.MarginPercent}" color="{outerDocument.setMarginColor(data.MarginPercent)}" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>


要感謝張睪0rz.......

沒有留言: