var dgCol:DataGridColumn = new DataGridColumn();
var factory:ClassFactory = new ClassFactory(ReportHTMLRenderer)
//here's where you can set a property in the itemrenderer...
factory.properties = {field:"some value"};
dgCol.itemRenderer = factory;


Here's the ItemRenderer class (ReportHTMLRenderer)...

package myComponents
{
import flash.errors.*;
import mx.controls.*;
import mx.controls.listClasses.IListItemRenderer;
import mx.core.IFactory;

public class ReportHTMLRenderer extends Text implements IFactory, IListItemRenderer
{
private var _data:Object;
private var _field:String = new String();

public function ReportHTMLRenderer(){
super();
this.percentHeight = 100;
this.percentWidth = 100;
}

public function newInstance():*{
return new ReportHTMLRenderer();
}

override public function set data(value:Object):void{
this._data = value;
this.htmlText = parseData(_data);
}

public function set field(str:String):void{
this._field = str;
}

private function parseData(item:Object):String{
try{
var xml:XML = XML(item);
var nodeName:String = _field;
return decodeURI(xml.child(nodeName).text());
}catch(e:Error){
return e.message;
}
}

}

 

출처: http://www.remwebdevelopment.com/dev/a11/Passing-Values-to-a-Custom-ItemRenderer.html

Posted by 미랭군