DataGrid的DataGridColumn内部如何调用外部method

<textarea cols="50" rows="15" name="code" class="c-sharp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;mx:Panel xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; xmlns:tenant=&quot;dps.component.tenant.*&quot; width=&quot;100%&quot; height=&quot;100%&quot; headerHeight=&quot;0&quot; initialize=&quot;init()&quot;&gt; &lt;mx:Script source=&quot;../../../DPSImage.as&quot;/&gt; &lt;mx:Script&gt; &lt;!--[CDATA[ import mx.events.EffectEvent; import mx.effects.Fade; import mx.events.DynamicEvent; import dps.model.GlobalEmployeeEntityBean; import dps.model.GlobalTenantEntityBean; import dps.control.TenantControl; import mx.collections.ArrayCollection; import mx.managers.PopUpManager; import mx.controls.Alert; import mx.core.Application; import dps.core.util.DateUtil; [Bindable] private var tenantInfo:ArrayCollection = new ArrayCollection( ); private var isPendingView:Boolean = true; public function init():void { TenantControl.getInstance().getTenantList(callback); function callback(data:ArrayCollection):void { tenantInfo = data; } } public function editTenant(data:GlobalTenantEntityBean):void { var addTenant:TenantAddView = TenantAddView(PopUpManager.createPopUp(Application.application as DisplayObject,TenantAddView,true)); addTenant.globalTenantEntityBean = data as GlobalTenantEntityBean; addTenant.addEventListener(&quot;UPDATE&quot;,refresh) PopUpManager.centerPopUp(addTenant); } public function refresh(event:DynamicEvent=null):void { init(); } private function tpLabelFunction(item:Object, column:DataGridColumn):String { var globalTenantEntityBean:GlobalTenantEntityBean = item as GlobalTenantEntityBean; var strTp:String = &quot;&quot;; if(globalTenantEntityBean.topManagers != null){ for(var j:int = 0; j&lt;globalTenantEntityBean.topManagers.length; j++){ strTp += GlobalEmployeeEntityBean((globalTenantEntityBean.topManagers)[j]).notesId + ','; } return strTp.substr(0,strTp.length-1); }else{ return &quot;&quot;; } } private function taLabelFunction(item:Object, column:DataGridColumn):String { var globalTenantEntityBean:GlobalTenantEntityBean = item as GlobalTenantEntityBean; var strTa:String = &quot;&quot;; if(globalTenantEntityBean.tenantAdmins != null){ for(var k:int = 0; k&lt;globalTenantEntityBean.tenantAdmins.length; k++){ strTa += GlobalEmployeeEntityBean((globalTenantEntityBean.tenantAdmins)[k]).notesId + ','; } return strTa.substr(0,strTa.length-1); }else{ return &quot;&quot;; } } private function labelFunction(item:Object, column:DataGridColumn):String { var globalTenantEntityBean:GlobalTenantEntityBean = item as GlobalTenantEntityBean; var strTa:String = &quot;&quot;; if(globalTenantEntityBean.contractStartDate != null&amp;&amp;globalTenantEntityBean.contractEndDate!=null) { strTa = globalTenantEntityBean.contractStartDate+&quot;~&quot;+globalTenantEntityBean.contractEndDate; return strTa.substr(0,strTa.length-1); }else{ return &quot;&quot;; } } public function changeViewClick():void { if(isPendingView) { lbl.text = &quot;Role Management&quot;; link.label = &quot;Tenant Management&quot;; } else { lbl.text = &quot;Tenant Management&quot;; link.label = &quot;Role Management&quot;; } changeView(); } public function changeView():void { var fa:Fade = new Fade(); if(isPendingView) { fa.target = tenantV; } else { fa.target = roleV; } fa.alphaTo = 0; fa.addEventListener(EffectEvent.EFFECT_END,effectEndFunction); fa.play(); function effectEndFunction(evt:EffectEvent):void { var fade:Fade = new Fade(); if(isPendingView) { tenantV.visible = false; tenantV.setStyle(&quot;alpha&quot;,0); fade.target = roleV; roleV.visible = true; } else { roleV.visible = false; roleV.setStyle(&quot;alpha&quot;,0); fade.target = tenantV; tenantV.visible = true; } isPendingView = !isPendingView; fade.alphaFrom = 0; fade.alphaTo = 1; fade.play(); } } ]]&gt; &lt;/mx:Script&gt; &lt;mx:Canvas width=&quot;100%&quot; height=&quot;100%&quot;&gt; &lt;mx:Canvas width=&quot;100%&quot; height=&quot;100%&quot;&gt; &lt;mx:Panel width=&quot;100%&quot; height=&quot;100%&quot;&gt; &lt;mx:DataGrid id=&quot;tenantV&quot; width=&quot;100%&quot; height=&quot;100%&quot; dataProvider=&quot;{tenantInfo}&quot;&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn headerText=&quot;Tenant Name&quot; dataField=&quot;tanentName&quot;/&gt; &lt;mx:DataGridColumn headerText=&quot;Top Manager&quot; labelFunction=&quot;tpLabelFunction&quot; /&gt; &lt;mx:DataGridColumn headerText=&quot;Tenant Admin&quot; labelFunction=&quot;taLabelFunction&quot;/&gt; &lt;mx:DataGridColumn headerText=&quot;Package&quot; dataField=&quot;rentFuncPacks&quot; /&gt; &lt;mx:DataGridColumn headerText=&quot;Contract Period&quot; labelFunction=&quot;labelFunction&quot;/&gt; &lt;mx:DataGridColumn headerText=&quot;Tenant Status&quot; dataField=&quot;tenantStatus&quot;/&gt; &lt;mx:DataGridColumn headerText=&quot;Description&quot; dataField=&quot;description&quot; sortable=&quot;false&quot;/&gt; &lt;mx:DataGridColumn width=&quot;60&quot;&gt; &lt;mx:itemRenderer&gt; &lt;mx:Component&gt; &lt;mx:HBox horizontalAlign=&quot;center&quot; verticalAlign=&quot;middle&quot; width=&quot;100%&quot; height=&quot;100%&quot;&gt; &lt;mx:Script source=&quot;../../../DPSImage.as&quot;/&gt; &lt;mx:Script&gt; &lt;![CDATA[ import dps.model.GlobalTenantEntityBean; import mx.events.DynamicEvent; import mx.managers.PopUpManager; import mx.core.Application; import dps.constant.Globalization; private function editItem(evt:MouseEvent):void { (outerDocument as TenantView).editTenant(data as GlobalTenantEntityBean); /*var addTenant:TenantAddView = TenantAddView(PopUpManager.createPopUp(Application.application as DisplayObject,TenantAddView,true)); addTenant.globalTenantEntityBean = data as GlobalTenantEntityBean; PopUpManager.centerPopUp(addTenant);*/ } ]]--&gt; &lt;/mx:Script&gt; &lt;mx:Image source=&quot;{editIcon}&quot; buttonMode=&quot;true&quot; toolTip=&quot;{Globalization.EDIT}&quot; click=&quot;editItem(event)&quot;/&gt; &lt;/mx:HBox&gt; &lt;/mx:Component&gt; &lt;/mx:itemRenderer&gt; &lt;/mx:DataGridColumn&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; &lt;/mx:Panel&gt; &lt;tenant:RoleManagementView width=&quot;100%&quot; height=&quot;100%&quot; visible=&quot;false&quot; id=&quot;roleV&quot;/&gt; &lt;/mx:Canvas&gt; &lt;mx:HBox width=&quot;100%&quot; verticalAlign=&quot;middle&quot; borderStyle=&quot;solid&quot; cornerRadius=&quot;5&quot; height=&quot;30&quot; backgroundColor=&quot;#FEE6AD&quot; paddingLeft=&quot;5&quot; paddingRight=&quot;5&quot;&gt; &lt;mx:Label text=&quot;Tenant Management&quot; fontWeight=&quot;bold&quot; id=&quot;lbl&quot; width=&quot;130&quot;/&gt; &lt;mx:VRule height=&quot;20&quot;/&gt; &lt;mx:LinkButton label=&quot;Role Management&quot; id=&quot;link&quot; styleName=&quot;blueLink&quot; click=&quot;changeViewClick()&quot;/&gt; &lt;mx:Spacer width=&quot;100%&quot;/&gt; &lt;/mx:HBox&gt; &lt;/mx:Canvas&gt; &lt;/mx:Panel&gt;</textarea>

你可能感兴趣的:(function,object,datagrid,String,callback,import)