我希望使用日期标签呈现我的datagrid标头。我正在使用以下代码。但是,当我运行实际应用程序时,我的标签不可见。有人可以建议吗?
import mx.controls.Label;
public class HeaderRenderer extends Label
{
private var lbl:Label;
private const LEFT_PADDING:int = 12;
public function HeaderRenderer()
{
super();
lbl = new Label();
lbl.visible=true;
lbl.text="Label";
}
override protected function updateDisplayList(w:Number, h:Number):void
{
lbl.x = LEFT_PADDING;
}
我从datagrid列访问它,如下所示。
<mx:columns>
<mx:DataGridColumn dataField="title" headerText="Task" width="{taskHeaderWidth}"/>
<mx:DataGridColumn itemRenderer="{ganttItemEditor}"
headerRenderer="{new ClassFactory(HeaderRenderer)}"
rendererIsEditor="true"
/>
</mx:columns>
答案 0 :(得分:0)
希望下面的代码可以帮助你: -
package
{
import mx.controls.listClasses.MXItemRenderer;
import spark.components.Label;
public class HeaderRenderer extends MXItemRenderer
{
private const LEFT_PADDING:int = 12;
private var lbl:Label;
public function HeaderRenderer()
{
super();
lbl = new Label();
lbl.visible=true;
lbl.text="Label";
this.addElement(lbl);
}
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);
lbl.x = LEFT_PADDING;
}
}
}