Flex DataGrid超链接和全选
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.logging.LogLogger;
import mx.logging.Log;
import mx.collections.ArrayCollection;
[Bindable]
private var demoArr:ArrayCollection=new ArrayCollection
([{orgName:'杭州',amt:3654,available:false},
{orgName:'嘉兴',amt:2000,available:false},
{orgName:'绍兴',amt:1000,available:false},
{orgName:'金华',amt:1200,available:false},
{orgName:'宁波',amt:1800,available:false},
{orgName:'台州',amt:560,available:false},
{orgName:'丽水',amt:2300,available:false},
{orgName:'湖州',amt:2900,available:false},
{orgName:'衢州',amt:2600,available:false},
{orgName:'温州',amt:1600,available:false},
{orgName:'舟山',amt:1300,available:false}])
//注意调用的方法是public的
public function clickEvent(o:Object):void{
Alert.show(o.amt);
}
public function multip():void{
ColumnUtil.getInstance().addCheckBox(dg1.columns[0],dg1);
ColumnUtil.getInstance().setHeadState(dg1);
}
]]>
</mx:Script>
<mx:VBox width="100%"
height="100%"
horizontalAlign="center">
<mx:DataGrid width="400"
height="500"
dataProvider="{this.demoArr}"
creationComplete="multip();"
id="dg1">
<mx:columns>
<mx:DataGridColumn id="dc1" dataField="available"/>
<mx:DataGridColumn headerText="单位">
<mx:itemRenderer>
<mx:Component>
<mx:LinkButton label="{data.orgName}"
color="blue"
textDecoration="underline"
click="outerDocument.clickEvent(data)">
</mx:LinkButton>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="金额"
dataField="amt">
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>
注意:在全选时,available非常重要,这里表示默认全不选,也可以设置默认选中部分。