股墓山庄

专注于AS3,JavaScript 每天一点进步,坚持...
  博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

DataGrid 表格中嵌入图片

Posted on 2012-03-10 00:07  股墓山庄庄主  阅读(404)  评论(0编辑  收藏  举报

主文件关键代码如下:

import fl.controls.listClasses.CellRenderer;
Arr.push({data:"images/ie.jpg",//此处要跟后面类中的名称一致
              "Job No.":JobListXML[i].@JobNo
             })
var colH:DataGridColumn = new DataGridColumn();
colH=DG.getColumnAt(DG.getColumnIndex("ico"));//这里是列名
colH.cellRenderer = LoaderCellRenderer;

 LoaderCellRenderer.as

 package {
         import fl.containers.UILoader;
         import fl.controls.listClasses.ICellRenderer;
         import fl.controls.listClasses.ListData;
         import fl.core.InvalidationType;
         import fl.data.DataProvider;
         import flash.events.Event;
         public class LoaderCellRenderer extends UILoader implements ICellRenderer {
             protected var _data:Object;
             protected var _listData:ListData;
             protected var _selected:Boolean;
             public function LoaderCellRenderer():void {
                 super();
             }
             public function get data():Object {
                 return _data;
             }     
             public function set data(value:Object):void {
                 _data = value;
                 source = value.data ;    //此处要跟前面的列名称一致
             }       
             public function get listData():ListData {
                 return _listData;
             }      
             public function set listData(value:ListData):void {
                 _listData = value;
                 invalidate(InvalidationType.DATA);
                 invalidate(InvalidationType.STATE);
             }     
             public function get selected():Boolean {
                 return _selected;
             }      
             public function set selected(value:Boolean):void {
                 _selected = value;
                 invalidate(InvalidationType.STATE);
             }   
            public function setMouseState(state:String):void {
            }
         }
     }