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
'플렉스·플래시·액션스크립트3' 카테고리의 다른 글
ItemRenderer Recycle 문제 (0) | 2012.11.29 |
---|---|
ItemRenderer 데이터 전달하기2 (0) | 2012.11.28 |
초를 일, 시간, 분 단위로 변환 (0) | 2012.11.20 |
BlazeDS와 Tomcat7 최신 버젼 호환성 (0) | 2012.11.06 |
amf 통신 시 규약 (0) | 2012.10.29 |