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.开发者_JAVA技巧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
First, I'd recommend you extend your custom headerRenderer from AdvancedDataGridHeaderRenderer
instead of AdvancedDataGridItemRenderer
.
Second, it looks like you are mixing the mx:DataGrid
with the mx:AdvancedDataGrid
. I guess that's the cause for your type coercion error. Make sure that your MXML looks something like this:
<mx:AdvancedDataGrid>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="foo" headerRenderer="myrenderers.theHeaderRenderer"/>
</mx:columns>
</mx:AdvancedDataGrid>
精彩评论