Flash datagrid嵌入ComboBox

好久没有更新博客了,变懒 了。继续努力。

datagrid中样式设置如下:

var colH:DataGridColumn = new DataGridColumn();
colH=DG.getColumnAt(DG.getColumnIndex(" "));
colH.cellRenderer = ComRenderer;

 

代码如下:

package {
        import fl.core.InvalidationType;
        import fl.controls.ComboBox;
        import fl.controls.listClasses.ICellRenderer;
        import fl.controls.listClasses.ListData;
        public class ComRenderer extends ComboBox implements ICellRenderer {
                private var _listData:ListData;
                private var _data:Object;
                private var _selected:Boolean;
                public function ComRenderer() {
                        super();
                        init();
                }
                private function init():void {
                        this.addItem({label:".to",data:0});
                        this.addItem({label:".fun",data:1});
                }
                override protected function draw():void {
                        if (isInvalid(InvalidationType.SELECTED)) {
                                _data.index = selectedIndex;
                        }
                        super.draw();
                }
                public function get listData():ListData {
                        return _listData;
                }
                public function set listData(value:ListData):void {
                        _listData = value;
                }
                public function get data():Object {
                        return _data;
                }
                public function set data(value:Object):void {
                        _data=value;
                        this.selectedIndex=value.index;
                }
                public function get selected():Boolean {
                        return _selected;
                }
                public function set selected(value:Boolean):void {
                        _selected=value;
                }
                public function setMouseState(state:String):void {
                }
        }
}

 

你可能感兴趣的:(datagrid)