2012-06-14 52 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属性已经公开,因此可以在不提供另一个属性的情况下设置完全相同的属性。