类扩展MX DataGrid如何实现allowMultipleSelection

时间:2012-06-14 14:10:06

标签: actionscript-3 flex flash-builder

我尝试使用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 个答案:

答案 0 :(得分:1)

当值始终为_footerAllowMultipleSelection时,您的代码仅检查allowMultipleSelection并在构造函数中设置false

allowMultipleSelection的设置器中设置footerAllowMultipleSelection属性。您还可以将_footerAllowMultipleSelection的初始值更改为true

但是你为什么要将它包装在一个吸气剂和装置中呢? allowMultipleSelection属性已经公开,因此可以设置它而不在子类中提供完全相同的其他属性。