FLEX2

 
FLEX的数据绑定:
 
指定数据源。
[Bindable]
private var arrayCollection:ArrayCollection = new ArrayCollection();
 
在DataGrid中使用绑定:
< mx:DataGrid y ="10" width ="805" x ="10" height ="168" dataProvider ="{arrayCollection}" id ="dataGrid" >
 
DataGrid中获得当前行的方法:
在Panel中定义mouseOver方法
在方法中计算行,从绑定的数据集中取出数据。
 
< mx:Script >
    <![CDATA[
      import comp.saveDataWindow;
        
      import mx.managers.PopUpManager;
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;
        
      [Bindable]
      private var arrayCollection:ArrayCollection = new ArrayCollection(); 
        
      
      public function getRows():void{
        
        var arrCollectionIndex:Number = Math.floor(dataGrid.contentMouseY/dataGrid.rowHeight) -1 + dataGrid.verticalScrollPosition;
        
        if( arrCollectionIndex < 0 || arrCollectionIndex > dataGrid.verticalScrollPosition + dataGrid.rowCount-1) {
            
        } else {
            
          this.showValue.text = arrayCollection.getItemAt(arrCollectionIndex).article.toString();
        }
        
      }
        
        
    ]]>
   </ mx:Script >

   < mx:Image x ="26" y ="10" source ="./image/title.jpg" />
   < mx:Panel width ="845" height ="196" layout ="absolute" horizontalCenter ="0" y ="81" title ="详细信息" fontSize ="12" themeColor ="#009DFF" >
     < mx:Text x ="10" y ="10" width ="805" id ="showValue" height ="134" />
   </ mx:Panel >
   < mx:Panel width ="845" height ="230" layout ="absolute" horizontalCenter ="0" y ="285" title ="列表" mouseOver ="getRows();" fontSize ="12" id ="dataPanel" >
    
     < mx:DataGrid y ="10" width ="805" x ="10" height ="168" dataProvider ="{arrayCollection}" id ="dataGrid" >
       < mx:columns >
         < mx:DataGridColumn headerText ="发言" dataField ="article" />
         < mx:DataGridColumn headerText ="选定" dataField ="isVote" width ="150" />
       </ mx:columns >
     </ mx:DataGrid >
    
   </ mx:Panel >
 
 
FLEX中的坐标:
Global:全局坐标,参考起点为0,0时,对应控件中的x,y的值;
Content:内容坐标,当前组件内部由用户输入内容组成的坐标
Local:组件内部坐标
 
 
DataGrid双击事件:
doubleClickEnabled="true" itemDoubleClick="changeData();"
 
public function changeData():void {
    var obj : Object = arrayCollection.getItemAt(dataGrid.selectedIndex) as Object;
    
    Alert(obj.toString());
    
//    obj.isVote = obj.isVote =="否" ? "无变化" : "是";changeVoteData
    if( obj.isVote=="否") {
     obj.isVote = "是";
    } else {
     obj.isVote = "否";
    }
    
    arrayCollection.setItemAt(obj, dataGrid.selectedIndex);
    
   }
        
        arrayCollection.setItemAt(obj, dataGrid.selectedIndex);

你可能感兴趣的:(职场,休闲)