Joshua
Joshua

Reputation: 6833

ItemFocusIn Not Working on Non-Editable DataGrid in Flex

I realize that ItemFocusIn is somehow only applicable to editable datagrids in flex, nevertheless I want to fire an event anytime the user selects a new row in a non-editable datagrid. I have successfully used the CLICK event, but this event is not fired when the user uses the keyboard to select a different row in the datagrid. What do I have to do to cause an event to fire whenever the currently highlighted row in the datagrid changes, regardless of weather it was changed by the mouse or by the keyboard?

Upvotes: 1

Views: 658

Answers (1)

Cornel Creanga
Cornel Creanga

Reputation: 5308

You should listen for selectedIndex change. Take a look at this code, the method dataGridselectedRowChanged is going to be called every time you change the row in the grid.

        public function set dataGridselectedRowChanged(id:int):void{
            trace(id);
        }
        <fx:Binding source="{myDG.selectedIndex}" destination="dataGridselectedRowChanged"/>
      <mx:DataGrid id="myDG"  width="350" >

Upvotes: 1

Related Questions