我已经设置了这样的itemrenderer包:
打包myrenderers { import mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer;
public class theHeaderRenderer extends AdvancedDataGridItemRenderer
{
public function theHeaderRenderer()
{
super();
setStyle("verticalAlign","middle");
}
}
}
但是,当我在AdvancedDataGridColumn标记中包含以下行时,
<fx:Component>
<myrenderers:theHeaderRenderer"/>
</fx:Component>
</mx:headerRenderer>
<fx:Component>
<renderers:someotherrenderer/>
</fx:Component>
</mx:itemRenderer>
我收到以下错误:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls.dataGridClasses::DataGridListData@ac84f81 to mx.controls.advancedDataGridClasses.AdvancedDataGridListData.
at mx.controls.advancedDataGridClasses::AdvancedDataGridItemRenderer/set listData()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\controls\advancedDataGridClasses\AdvancedDataGridItemRenderer.as:232]
at mx.controls::DataGrid/http://www.adobe.com/2006/flex/mx/internal::calculateHeaderHeight()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\DataGrid.as:2182]
at mx.controls.dataGridClasses::DataGridHeader/measure()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\dataGridClasses\DataGridHeader.as:201]
at mx.core::UIComponent/measureSizes()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8216]
at mx.core::UIComponent/validateSize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8140]
at mx.managers::LayoutManager/validateSize()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:617]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:709]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
有谁能建议我如何遇到这个问题?
谢谢
答案 0 :(得分:0)
首先,我建议您从AdvancedDataGridHeaderRenderer
而不是AdvancedDataGridItemRenderer
扩展自定义headerRenderer。
其次,看起来您正在混合mx:DataGrid
和mx:AdvancedDataGrid
。我猜这是你的类型强制错误的原因。确保您的MXML看起来像这样:
<mx:AdvancedDataGrid>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="foo" headerRenderer="myrenderers.theHeaderRenderer"/>
</mx:columns>
</mx:AdvancedDataGrid>