我试图渲染一些html文本,其中大约10个字符串与Datagrigd列中的字符串连接在一起。我可以渲染它,但不能渲染到单元格的大小。我试图将其嵌入HBox中,然后将其放入细胞中。但我不能调整大小,因为我看到HBox正在缩小,即使单元格中有足够的空间。有人可以帮助我将这个HBox拟合到Datagrid单元格的大小。
我尝试使用UpdateDisplayList()但它进入无限循环并且屏幕正在冻结。请找到以下代码。
下面是我打电话给渲染器的班级。有人可以帮帮我。
包components.myReports { import mx.collections.ArrayCollection; import mx.containers.HBox; import mx.containers.VBox; import mx.controls.DataGrid; import mx.controls.dataGridClasses.DataGridColumn; import mx.core.ClassFactory; import renderers.HtmlTextRenderer;
public class MyReportsComponent extends VBox
{
[Bindable]
// public var metersList:ArrayCollection = model.Lookups.getInstance()。metersList;
private var _reportsList:ArrayCollection;
private var myReports:ArrayCollection = new ArrayCollection([
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:"" },
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""},
{name:"Christina Coenraets",description:"myReports1", dateRefreshed:"05-18-2009", dateCreated:"05-18-2009" , scheduledTime: "05-18-2009",operations:""}
]);
public function MyReportsComponent()
{
//TODO: implement function
super();
}
public function set reportsList(arr:ArrayCollection):void{
_reportsList = arr
}
override protected function createChildren():void {
var dataGrid:DataGrid ;
var dataGridColumn:DataGridColumn;
var mainContainer:HBox;
this.removeAllChildren();
mainContainer = new HBox();
mainContainer.width = this.parent.width;
mainContainer.minHeight = 1000;
mainContainer.horizontalScrollPolicy = "off";
mainContainer.verticalScrollPolicy = "of";
mainContainer.percentHeight = 100;
mainContainer.percentWidth = 75;
dataGrid = new DataGrid();
var row:Array=new Array("name","description","dateRefreshed","dateCreated","scheduledTime","operations");
var colName:String;
var gridcolumns:Array=new Array();
for(var i:int=0;i<row.length;i++)
{
dataGridColumn=new DataGridColumn();
dataGridColumn.dataField=row[i].toString();
trace(row[i].toString());
if(row[i].toString()== "operations")
{
dataGridColumn.itemRenderer = new ClassFactory(HtmlTextRenderer);
dataGridColumn.width = 200;
}else {
dataGridColumn.width = 70;
}
dataGridColumn.resizable=true;
gridcolumns.push(dataGridColumn);
}
dataGrid.columns = gridcolumns;
dataGrid.width = 700;
dataGrid.height= 400;
dataGrid.dataProvider = myReports;
mainContainer.addChild(dataGrid);
this.addChild(mainContainer);
this.validateNow();
}
}
}
渲染-----
包装渲染器 { import mx.containers.HBox; import mx.controls.TextArea;
public class HtmlTextRenderer extends HBox
{
private var text:Array=new Array("Edit","Delete","Run","EMail","RetrieveFile","Public","Private","SharedReport","ScheduledReport");
private var html:String = null;
public var operations:TextArea;
public function HtmlTextRenderer()
{
//TODO: implement function
super();
}
override protected function createChildren():void
{
super.createChildren();
for(var i:int = 0 ;i < text.length ;i++)
{
html+=targetHTML(text[i].toString());
}
operations = new TextArea();
operations.htmlText = html;
this.percentWidth = 100;
this.percentHeight = 100;
this.addChild(operations);
}
private function targetHTML(name:String):String
{
return "<a href='event:" + name + "'>" + name + "</a>";
}
/* override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth,unscaledHeight);
} */
private function updateSize()
{
var w:int = this.measuredWidth +100;
trace("The width of the Text is "+this.measuredWidth);
this.width = w;
this.parent.width = w;
}
}
}
答案 0 :(得分:0)
您是否尝试将项目渲染器简单地设为textArea?