Flexd的dataGrid控件使用(事件调用外部函数)

来源:互联网 发布:广州手趣网络 招聘 编辑:程序博客网 时间:2024/05/29 03:20

 

dataGrid示例

在dataGrid里添加各种控件。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml"
 width="100%" height="100%" top="0">
 <mx:Script>
  <![CDATA[
  import mx.controls.Alert;
  import com.dashboard.view.*;
  
  private function traceShenBaoInfo(e:Event):void
  {
   var info:ShenBaoInfoNext = new ShenBaoInfoNext();
   var parentPod:Pod = parent as Pod;
   Alert.show(String(e.currentTarget.getRepeaterItem()));
   parentPod.historyArray.push(this);
   /******/
   trace(parent);
   
   parentPod.addChild(info);
   parentPod.removeChild(this);
  }  
  private function initReceiveText():void {
   var parentPod:Pod = parent as Pod;
   var currSpc:ShenBaoList= parentPod.historyArray[2] as ShenBaoList;
   if(currSpc!=null){
   titlelable.text = currSpc.setUrlData.text;
   }
  // Alert.show(String(currSpc.rp.currentTarget.getRepeaterItem()));
  }
  private function setXmlData():void{
   var dateGridXml:XML= <employee>
               <id>1</id>
               <list>招掉工审查表</list>
               <type>在线填报</type>
               <mode>填报</mode>
              </employee>;
         <employee>
               <id>1</id>
               <list>招掉工审查表</list>
               <type>在线填报</type>
               <mode>填报</mode>
              </employee>;
               <employee>
               <id>1</id>
               <list>招掉工审查表</list>
               <type>在线填报</type>
               <mode>填报</mode>
              </employee>;
        dg.dataProvider=dateGridXml
  }
  public function upload():void
  {
   Alert.show(dg.currentState);
  }
  ]]>
 </mx:Script>
 
<mx:VBox width="100%" height="100%" paddingTop="0" paddingRight="0" paddingLeft="0" paddingBottom="0">
 <mx:Label id="titlelable" width="100%" color="blue" />
   <mx:DataGrid id="dg" width="80%" height="100%" rowCount="5" initialize="setXmlData();">
            <mx:columns>
                <mx:DataGridColumn width="20" headerText="序号">
                 <mx:itemRenderer>
                  <mx:Component>
                   <mx:Text text="{data.id}"/>
                  </mx:Component>
                 </mx:itemRenderer>
                </mx:DataGridColumn>

                <mx:DataGridColumn width="180" dataField="list" headerText="材料清单">
                 <mx:itemRenderer>
                  <mx:Component>
                   <mx:Text text="{data.list}"/>
                  </mx:Component>
                 </mx:itemRenderer>
                </mx:DataGridColumn>
                <mx:DataGridColumn dataField="type" headerText="申报类型">
                 <mx:itemRenderer>
                  <mx:Component>
                   <mx:Text text="{data.type}"/>
                  </mx:Component>
                 </mx:itemRenderer>
                </mx:DataGridColumn>
                <mx:DataGridColumn dataField="mode" headerText="方式">
                 <mx:itemRenderer>
                  <mx:Component>
                   <mx:Button label="{data.mode}" click="outerDocument.upload();"/>
                  </mx:Component>
                 </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>
  
  </mx:VBox> 
</mx:Application>

*在<mx:component>里面的事件用outerDocument调用外部的方法名。但必须是public的。

原创粉丝点击