理解 Flex itemRenderer - 第 2 部分: 外部渲染器(转)
MXML ITEMRENDERER
在第 1 部分中, 您看到有一个复杂的 itemRenderer 用于 DataGrid:
<mx:DataGridColumn headerText="Title" dataField="title"><mx:itemRenderer><mx:Component><mx:HBox paddingLeft="2"><mx:Script><![CDATA[override public function set data( value:Object ) : void {super.data = value;var today:Number = (new Date()).time;var pubDate:Number = Date.parse(data.date);if( pubDate > today ) setStyle("backgroundColor",0xff99ff);else setStyle("backgroundColor",0xffffff);}]]></mx:Script><mx:Image source="{data.image}" width="50" height="50" scaleContent="true" /><mx:Text width="100%" text="{data.title}" /></mx:HBox></mx:Component></mx:itemRenderer></mx:DataGridColumn>
<?xml version="1.0" encoding="utf-8"?><mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300"><mx:Script><![CDATA[override public function set data( value:Object ) : void {super.data = value;var today:Number = (new Date()).time;var pubDate:Number = Date.parse(data.date);if( pubDate > today ) setStyle("backgroundColor",0xff99ff);else setStyle("backgroundColor",0xffffff);}]]></mx:Script><mx:Image source="{data.image}" width="50" height="50" scaleContent="true" /><mx:Text width="100%" text="{data.title}" /></mx:HBox>保存此文件。
<mx:DataGridColumn headerText="Title" dataField="title"itemRenderer="GridColumnSimpleRenderer">