复制代码 代码如下:
<mx:DataGrid id="dg" click="select()" dataProvider= "{modelLocator.resultList}" border
verticalGridLines="false" horizontalGridLines="false" verticalScrollPolicy="off" rowCount="10"
fontSize="16" font fontThickness="0" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn dataField="programName " headerText="节目名称" >
<mx:itemRenderer>
<mx:Component>
<mx:HBox width="100%" height="100%" horizontalAlign="left" verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
override public function set data (value:Object):void
{
if(value != null)
{
super.data = value;
programXYZ.htmlText = data.programName;
//Alert.show(this.programXYZ.text);
}
}
]]>
</mx:Script>
<mx:Text id="programXYZ" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
关键是重写了 override public function set data(value:Object):void 方法