[ 
https://issues.apache.org/jira/browse/FLEX-34022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13861973#comment-13861973
 ] 

Justin Mclean edited comment on FLEX-34022 at 1/3/14 10:44 PM:
---------------------------------------------------------------

Thanks for raising the issue and providing the code sample, makes investigating 
bugs much easier.

However don't think this is an issue as DataGrid item renderers need to 
implement IGridItemRenderer.  If you use DefaultGridItemRenderer rather than 
DefaultItemRenderer the sample code will work (or alternatively comment out the 
itemRenderer line). DefaultItemRenderer is the default item renderer for List 
components not DataGrid components.


was (Author: jmclean):
Thanks for raising the issue and providing the code sample, make investigating 
bugs much easier.

However don't think this is an issue as DataGrid item renderers need to 
implement IGridItemRenderer.  If you use DefaultGridItemRenderer rather than 
DefaultItemRenderer the sample code will work (or alternatively comment out the 
itemRenderer line). DefaultItemRenderer is the default item renderer for List 
components not DataGrid components.

> Null object reference when setting columns on Spark DataGrid
> ------------------------------------------------------------
>
>                 Key: FLEX-34022
>                 URL: https://issues.apache.org/jira/browse/FLEX-34022
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: DataGrid
>    Affects Versions: Apache Flex 4.9.0, Apache Flex 4.11.0
>         Environment: Mac OS X
>            Reporter: Curtis Aube
>            Assignee: Justin Mclean
>
> If you set a bindable columns property for the DataGrid before it is 
> initialized and set an itemRenderer for one of the columns, you get a null 
> object reference when the DataGrid is initialized.
> Here is an example:
> <?xml version="1.0" encoding="utf-8"?>
> <s:Application creationComplete="creationComplete()" minHeight="600" 
> minWidth="955" preinitialize="setColumns()" 
> xmlns:fx="http://ns.adobe.com/mxml/2009"; 
> xmlns:mx="library://ns.adobe.com/flex/mx"
>                          xmlns:s="library://ns.adobe.com/flex/spark">
>       <fx:Script>
>               <![CDATA[
>                       import mx.collections.ArrayCollection;
>                       import mx.collections.ArrayList;
>                       import spark.components.gridClasses.GridColumn;
>                       import spark.skins.spark.DefaultItemRenderer;
>                       [Bindable]
>                       private var columns:ArrayList;
>                       [Bindable]
>                       private var dp:ArrayCollection;
>                       private function creationComplete():void
>                       {
>                               var myHistoryItems:Array = new Array;
>                               myHistoryItems.push({filename: "Testing"});
>                               dp = new ArrayCollection(myHistoryItems);
>                       }
>                       private function setColumns():void
>                       {
>                               var column:GridColumn
>                               var myColumns:ArrayList = new ArrayList;
>                               column = new GridColumn("filename");
>                               column.headerText = "Filename";
>                               column.itemRenderer = new 
> ClassFactory(DefaultItemRenderer);
>                               myColumns.addItem(column);
>                               columns = myColumns;
>                       }
>               ]]>
>       </fx:Script>
>       <s:DataGrid height="100%" width="100%" columns="{columns}" 
> dataProvider="{dp}"/>
> </s:Application>
> Here is the stack trace:
> TypeError: Error #1009: Cannot access a property or method of a null object 
> reference.
>       at 
> spark.components::Group/addElement()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1395]
>       at 
> spark.components.gridClasses::GridLayout/createTypicalItemRenderer()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as:756]
>       at 
> spark.components.gridClasses::GridLayout/updateTypicalCellSizes()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as:891]
>       at 
> spark.components.gridClasses::GridLayout/measure()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as:452]
>       at 
> spark.components.supportClasses::GroupBase/measure()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as:1156]
>       at 
> mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::measureSizes()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:8514]
>       at 
> mx.core::UIComponent/validateSize()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/core/UIComponent.as:8438]
>       at 
> spark.components::Group/validateSize()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/spark/src/spark/components/Group.as:1065]
>       at 
> mx.managers::LayoutManager/validateSize()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:673]
>       at 
> mx.managers::LayoutManager/doPhasedInstantiation()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:800]
>       at 
> mx.managers::LayoutManager/doPhasedInstantiationCallback()[/Users/justinmclean/Documents/ApacheFlexSDK/frameworks/projects/framework/src/mx/managers/LayoutManager.as:1188]



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to