1 Reply Latest reply on Jan 8, 2007 12:02 PM by FlightGuy

    createItemEditor TypeError Exception

    mrbahr Level 1

      I am getting:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.controls::DataGrid/createItemEditor()[C:\dev\GMC\sdk\frameworks\mx\controls\DataGrid.a s:3339]

      Here is the scenario. I have a data grid that I use to allow users to enter data and when they press "enter", we clear the grid and start prompting again. This exception is thrown after the grid is successfully filled out once and the save button is pressed. It looks like this has to do with the item editor, but I can't figure out where.

      My grid looks like the following:

      <mx:DataGrid id="icd9Grid" x="10" y="50" width="298" height="108" editable="true"
      <mx:DataGridColumn headerText="Ln" dataField="lineNumber" width="30" editable="false"/>
      <mx:DataGridColumn headerText="Ov" dataField="Ov" width="30" editable="false" />
      <mx:DataGridColumn id="icd9Code" headerText="ICD-9" width="75" dataField="icd9Code"
      <!-- itemEditor="com.presidioClient.view.coder.EditorICD9AutoComplete" -->
      <mx:ComboBox dataProvider="{outerDocument.icd9List}" dropdownWidth="320"
      labelField="icd9Code" editable="true" text="{data.icd9Code}" prompt="">
      <mx:Label text="{data.icd9Code}" width="65"/>
      <mx:Label text="{data.icd9Description}" width="210"/>
      <mx:DataGridColumn headerText="Description" dataField="icd9Desc" editable="false"/>

      This grid is bound to an object that is created when the parent canvas is displayed. When the user presses save, the object is persisted, destroyed and a new object created and bound to the grid. This exception is thrown after all of the initialization is completed and the dataProviders have been set. It looks like it might be some sort of timing issue, but I'm not sure. It works every once in a while, but most of the time, fails with the following exception.

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.controls::DataGrid/createItemEditor()[C:\dev\GMC\sdk\frameworks\mx\controls\DataGrid.a s:3339]
      at mx.controls::DataGrid/mx.controls:DataGrid::itemEditorItemEditBeginHandler()[C:\dev\GMC\s dk\frameworks\mx\controls\DataGrid.as:4566]
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.controls::DataGrid/mx.controls:DataGrid::commitEditedItemPosition()[C:\dev\GMC\sdk\fra meworks\mx\controls\DataGrid.as:3253]
      at mx.controls::DataGrid/mx.controls:DataGrid::updateDisplayList()[C:\dev\GMC\sdk\frameworks \mx\controls\DataGrid.as:1220]
      at mx.core::UIComponent/validateDisplayList()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent. as:5672]
      at mx.managers::LayoutManager/mx.managers:LayoutManager::validateDisplayList()[C:\dev\GMC\sd k\frameworks\mx\managers\LayoutManager.as:594]
      at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[C:\dev\GMC\ sdk\frameworks\mx\managers\LayoutManager.as:664]
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\sdk\framework s\mx\core\UIComponent.as:7789]
      at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\sdk\frameworks \mx\core\UIComponent.as:7732]

      Any thoughts?

        • 1. Re: createItemEditor TypeError Exception
          FlightGuy Level 1
          This failure is happening where flex is attempting to position an itemEditor. The itemEditorInstance must have been successfully created, since there are other properties assigned before this line, so it must be one of the two objects used in the parameters. Here's the culprit line:

          3339: itemEditorInstance.move(item.x + dx, rowData.y + dy);

          item is assigned from listItems[rowIndex][colIndex]
          rowData is assigned from rowInfo[rowIndex]

          You'd be able to see in the debugger which of these is ending up as null, but it does seem to be a timing issue when you reassign the source data.

          How do you assign data to icd9Grid? You might try defining a Bindable variable in script, and then assign the dataProvider="{myDataProvider}" on the DataGrid mxml.

          private var myDataProvider:ArrayCollection;

          Then when you've completed your action and want to reassign the data, set myDataProvider=myNewData. This will allow the DataGrid to deal with the binding in a more tried-and-tested way.