Flex Error 1009 when clicking on DataGrid Header to sort.

Encountered this error while working with a datagrid and using the itemClick property to select and item from the datagrid.

 

The solution is to use the "change" property and pass a ListEvent to your handler function. I was using the click property on the datagrid and pass a MouseEvent to the handler function. The change function does not get fired when the header is clicked and now error 1009. See before and after code below.

 

BEFORE CODE

<mx:Script>
    <![CDATA[

    private function clickHandler(event:MouseEvent):void
    {
        trace(Click Handler;);
    }   

]]>

</mx:Script>

<mx:DataGrid width="100%" height="100%"
    dataProvider="{myAC}"
    click="clickHandler(event)">
    <mx:columns>
        <mx:DataGridColumn headerText="Title" dataField="title"/>
    </mx:columns>
</mx:DataGrid>

 

AFTER CODE

<mx:Script>
    <![CDATA[

    private function changeHandler(event:ListEvent):void
    {
        trace('Change Handler;);
    }

]]>

</mx:Script>

<mx:DataGrid width="100%" height="100%"
    dataProvider="{myAC}"
    change="changeHandler(event)">
    <mx:columns>
        <mx:DataGridColumn headerText="Title" dataField="title"/>
    </mx:columns>
</mx:DataGrid>

 

0 responses to “Flex Error 1009 when clicking on DataGrid Header to sort.”

Leave a Reply

Leave this field empty:

Powered by Mango Blog.