扩展 AdvancedDataGridRenderer 时出错
我已经像这样设置了 itemrenderer 包:
package myrenderers { 导入 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:错误 #1034:类型强制失败:无法将 mx.controls.dataGridClasses::DataGridListData@ac84f81 转换为 mx.controls.advancedDataGridClasses.AdvancedDataGridListData。 在 mx.controls.advancedDataGridClasses::AdvancedDataGridItemRenderer/set listData()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\controls\advancedDataGridClasses\AdvancedDataGridItemRenderer.as:232] 在 mx.controls::DataGrid/http://www.adobe.com/2006/flex/mx/internal::calculateHeaderHeight()[E:\dev\4.x\frameworks\projects\framework\src\mx\控件\DataGrid.as:2182] 在 mx.controls.dataGridClasses::DataGridHeader/measure()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\dataGridClasses\DataGridHeader.as:201] 在 mx.core::UIComponent/measureSizes()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8216] 在 mx.core::UIComponent/validateSize()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8140] 在 mx.managers::LayoutManager/validateSize()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:617] 在 mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:709] 在 mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
任何人都可以建议我如何来跨越这个问题?
谢谢
I have set the itemrenderer package like that:
package myrenderers
{
import mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer;
public class theHeaderRenderer extends AdvancedDataGridItemRenderer
{
public function theHeaderRenderer()
{
super();
setStyle("verticalAlign","middle");
}
}
}
However when I include the following lines in my AdvancedDataGridColumn tag,
<fx:Component>
<myrenderers:theHeaderRenderer"/>
</fx:Component>
</mx:headerRenderer>
<fx:Component>
<renderers:someotherrenderer/>
</fx:Component>
</mx:itemRenderer>
I get the following error:
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]
Can anyone suggest how I can come across this problem?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我建议您从
AdvancedDataGridHeaderRenderer
而不是AdvancedDataGridItemRenderer
扩展自定义 headerRenderer。其次,看起来您正在将
mx:DataGrid
与mx:AdvancedDataGrid
混合在一起。我想这就是你的类型强制错误的原因。确保您的 MXML 看起来像这样:First, I'd recommend you extend your custom headerRenderer from
AdvancedDataGridHeaderRenderer
instead ofAdvancedDataGridItemRenderer
.Second, it looks like you are mixing the
mx:DataGrid
with themx:AdvancedDataGrid
. I guess that's the cause for your type coercion error. Make sure that your MXML looks something like this: