Responding to ItemClick events in rows, not the headers


I have a functional datagrid that responds to itemClick events. Everything works, except that it also triggers the itemClick event when the headers are clicked. So instead of sorting the grid data they trigger the event which changes the state. I want to only have the click event respond to the rows being clicked, not the headers.

I have googled everywhere and dug through my books and every example i've seen seems to work, so i'm wondering what i am doing wrong here:


            public var acPrograms:ArrayCollection;

            private function showGameDetail(event:ListEvent):void {
                var programEvent:ProgramsEvent = new ProgramsEvent(ProgramsEvent.SHOW_DETAIL);
                programEvent.selectedProgram = TvPrograms( event.currentTarget.selectedItem );

                currentState = "details";

    <mx:DataGrid id="gamesGrid" height="270" dataProvider="{acPrograms}"
                <mx:DataGridColumn headerText="Date" dataField="dateOutput" width="90" />
                <mx:DataGridColumn headerText="Time" dataField="startTime" width="70" />
                <mx:DataGridColumn headerText="Title" dataField="subTitle" width="360" />
                <mx:DataGridColumn headerText="Channel" dataField="channel" width="80" />
                <mx:DataGridColumn headerText="Provider" dataField="provider" width="100" />


The real issue here was my cache settings. I was working with a cached version that had a click event instead of an itemClick. So the click event responds to all clicks on the grid and the itemClick does as desired, all I needed to to was turn off my cache. Bonehead on my part, But thanks for the help.

Best Solution

how about adding the following in your event handler?

if (event.rowIndex < 0) 
Related Question