2012-06-14 53 views
0

我嘗試使用allowMultipleSelection屬性實現頁腳datagrid。 但在我的情況下,它似乎不工作。 你能幫我實現這個功能嗎?類擴展MX DataGrid如何實現allowMultipleSelection

感謝

package fr.component.dgFooter 
{ 
    import mx.controls.DataGrid; 
    import mx.controls.dataGridClasses.DataGridColumn; 

    public class FooterDataGrid extends DataGrid 
    { 
     protected var _footerAllowMultipleSelection:Boolean=false; 





     public function FooterDataGrid() 
     { 
      super(); 
      if(_footerAllowMultipleSelection){ 
       this.allowMultipleSelection=true; 
      } 
      else{ 

      } 
     } 

     public function get footerAllowMultipleSelection():Boolean 
     { 
      return _footerAllowMultipleSelection; 
     } 

     public function set footerAllowMultipleSelection(value:Boolean):void 
     { 
      _footerAllowMultipleSelection = value; 
     } 

     protected var footer:DataGridFooter; 

     protected var footerHeight:int = 22; 



     override protected function createChildren():void 
     { 
      super.createChildren(); 

      if (!footer) 
      { 
       footer = new DataGridFooter(); 
       footer.styleName = this; 
       addChild(footer); 
      } 
     } 

     override protected function adjustListContent(unscaledWidth:Number = -1, 
      unscaledHeight:Number = -1):void 
     { 
      super.adjustListContent(unscaledWidth, unscaledHeight); 

      listContent.setActualSize(listContent.width, listContent.height - footerHeight); 
      //this deals w/ having locked columns - it's handled differently in 
      //the dg and the adg 
      footer.setActualSize(listContent.width+listContent.x, footerHeight); 
      footer.move(1, listContent.y + listContent.height + 1); 
     } 

     override public function invalidateDisplayList():void 
     { 
      super.invalidateDisplayList(); 
      if (footer) 
       footer.invalidateDisplayList(); 
     } 
    } 

} 

回答

1

你的代碼只檢查_footerAllowMultipleSelection,並設置allowMultipleSelection在構造函數中,當值始終false

在設置者footerAllowMultipleSelection中設置allowMultipleSelection屬性。您還可以將初始值_footerAllowMultipleSelection更改爲true

但是,爲什麼你把它包裝在一個吸氣和二傳手呢? allowMultipleSelection屬性已經公開,因此可以在不提供另一個屬性的情況下設置完全相同的屬性。