您的位置:首页 > 其它

<mx:itemRenderer>使用

2011-08-31 11:45 447 查看
<mx:itemRenderer>标签中的要素时间调用外部要素 :代码红色部分




<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Embed(source='assets/myimages/gl.png')]
[Bindable] public var ssjcgl:Class;

[Bindable]
private var dp:ArrayCollection=new ArrayCollection
([{name:'张村监测站',sw:36,no:1,level:"警戒"},
{name:'王村监测站',sw:20,no:1,level:"危险"})

//注意调用的方法是public的
public function clickEvent(o:Object):void{
log.debug(o);
}

public function test(o:Object):void{
log.debug(o);
}
public function test2(o:Object):void{
log.debug(o);
}
]]>
</mx:Script>

<mx:VBox width="100%"
height="100%"
horizontalAlign="center">
<mx:DataGrid width="400"
height="500"
dataProvider="{dp}">
<mx:columns>
<mx:DataGridColumn headerText="站名">
<mx:itemRenderer>
<mx:Component>
<mx:LinkButton label="{data.name}"
textDecoration="underline"
click="outerDocument.clickEvent(data)">
</mx:LinkButton>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>

<mx:DataGridColumn headerText="雨量"
dataField="sw">
</mx:DataGridColumn>

<mx:DataGridColumn headerText="预警级别"
dataField="level">
</mx:DataGridColumn>

<mx:DataGridColumn headerText="关联信息">
<mx:itemRenderer>
<fx:Component>
<mx:HBox horizontalAlign="center">
<mx:Image source="{outerDocument.ssjcgl}" click="outerDocument.test1(data.no)" toolTip="乡镇" buttonMode="true" useHandCursor="true" /
<mx:Image source="{outerDocument.ssjcgl}" click="outerDocument.test2(data.no)" toolTip="小流域" buttonMode="true" useHandCursor="true" />  </mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>

<mx:Image source="{outerDocument.ssjcgl}" click="outerDocument.test1(data.no)" toolTip="乡镇" buttonMode="true" useHandCursor="true" /
<mx:Image source="{outerDocument.ssjcgl}" click="outerDocument.test2(data.no)" toolTip="小流域" buttonMode="true"
必须放在一个容器中否则会出错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: