0

I was developing an app that in the first state you choose a date range using dataFields then you press a button to go to another state and generate a datagrid showing an employee list and another scrollable datagrid with its columns generated dynamically having the worked hours for every employee in every date.

The step sequence to get the error message is:

  1. You choose a date range for example: from 01/01/2013 to 01/31/2013
  2. You press generate button (The app change the currentState = "EmployeeList" and all is OK)
  3. You press the back button (you return to initial state and all is OK)
  4. If you change the date range having more days than before date range then all is OK
  5. If you change the date range having less days than before date range then next error is reached

    TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls.dataGridClasses::DataGridBase/http://www.adobe.com/2006/flex/mx/internal::columnHeaderWordWrap() at mx.controls.dataGridClasses::DataGridItemRenderer/validateProperties() at mx.managers::LayoutManager/validateClient() at mx.controls.dataGridClasses::DataGridHeader/updateDisplayList() at mx.core::UIComponent/validateDisplayList() at mx.managers::LayoutManager/validateDisplayList() at mx.managers::LayoutManager/doPhasedInstantiation() at mx.managers::LayoutManager/doPhasedInstantiationCallback()

and if you google it then some results take to visit apache bug reporting site

https://issues.apache.org/jira/browse/FLEX-22108

And there is no more...

But I found how to solve it!

Yury Euceda
  • 570
  • 4
  • 15

1 Answers1

1

To solve it first of all I was googling a lot and i looks like no one got this error and I discover that is a Flex Bug reported to Apache. And I was analyzing the original code from DataGrid.as and DataGridColumn.as to think about a possible solution and I was making some tests and nothing work.

What I did and I hope it will be useful to someone

when you click the back button, inside the backbutton_clickEventLister() and before currentState=""; I just set columns array to new Array();

protected function bttnBack_clickEventHandler(event:Event) : void {
    // This code line solved it
    dtGrdWorkedHours.columns = new Array();
    // Make sure of code it before state change stament
    currentState = "";
}
Yury Euceda
  • 570
  • 4
  • 15
  • 1
    Ah, yes this little bugger. Also make sure to set dataProvider to new ArrayCollection() (or any empty IList) instead of null if you mean to reset the data, or similar shenanigans will ensue. – drkstr101 Sep 18 '13 at 22:35