istrasci
istrasci

Reputation: 1351

Flex DataGrid List highlighting

By default, whenever you rollOver/mouseOver (not sure of the difference) an item in a Datagrid or a List, that item is highlighted with the component's rollOverColor. I'm just wondering if there's any way to do that programmatically. I haven't been able to find much help on the issue. For example, suppose I have two DataGrids. When I rollOver an item in the first DataGrid, I want to highlight the corresponding index in the second one as well. Basically, as if two separate cursors were rollOver'ing two separate DataGrids. How can I do this?

Upvotes: 1

Views: 1253

Answers (2)

Florian F
Florian F

Reputation: 8875

1) Create a custom DataGrid with this function :

public function indicesToItemRenderer(rowIndex:int, colIndex:int):IListItemRenderer
    {
        var firstItemIndex:int = verticalScrollPosition - offscreenExtraRowsTop;
        if (rowIndex < firstItemIndex ||
                rowIndex >= firstItemIndex + listItems.length
                )
        {
                return null;
        }

        return listItems[rowIndex - firstItemIndex][colIndex];
    }

2) When you want to hightlight an item, call this code :

youCustomADG.indicesToItemRenderer(idxRow, idxCol).dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OVER);

Upvotes: 0

Jonathan Dumaine
Jonathan Dumaine

Reputation: 5756

You can listen for the datagrid's itemRollOver event and then select a row in the other datagrid by using it's selectedIndex or selectedItem properties.

Upvotes: 1

Related Questions