data grid selection
how can i do in DataGrid after mouse right button click actual item under mouse will select (same as mous开发者_运维百科e left button click)
thanks for helpI 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!
精彩评论