<mx:itemRenderer>使用

<mx:itemRenderer>标签中的要素时间调用外部要素 :代码红色部分

mx:itemRenderer使用 - justcode.w - 伊柯丽斯的博客
 
<?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"
必须放在一个容器中否则会出错。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值