Pavel Severýn
Pavel Severýn

Reputation: 255

data grid selection

how can i do in DataGrid after mouse right button click actual item under mouse will select (same as mouse left button click)
thanks for help

Upvotes: 2

Views: 856

Answers (1)

Constantiner
Constantiner

Reputation: 14221

I recommend you to extend your DataGrid and introduce there a new field:

public var currentOverItem:Object;

Then override mouseOverHandler() in your custom DataGrid the following way:

    override protected function mouseOverHandler(event:MouseEvent):void
    {
        super.mouseOverHandler(event);
        var item:IListItemRenderer = mouseEventToItemRenderer(event);
        if (item)
        {
            currentOverItem = item.data;
        }
        else
        {
            currentOverItem = null;
        }
    }

Using of this DataGrid is pretty simple. Just subscribe ContextMenuEvent.MENU_SELECT event of the instance of your custom DataGrid and use the following code in context menu handler:

            myGrid.selectedItem = myGrid.currentOverItem;

Hope this helps!

Upvotes: 4

Related Questions