Assign a menu item(on right click menu list) to DataGrid control in Flex.

OK, First thing to do, read about flash.ui.ContextMenu Class.
Some points..
->In SWF content, any object that inherits from InteractiveObject can be given a context menu by assigning a menu object to its contextMenu property.
->In Flex, only top-level components in the application can have context menus.
->Flash Player has three types of context menus:standard menu ,the edit menu and an error menu.Only the standard and edit menus can be modified with the ContextMenu class.

so first create a ContextMenu for the DataGrid like below..

private function fnDgContextMenu():ContextMenu
{
var newContextMenu:ContextMenu = new ContextMenu();
var newContextMenuItem:ContextMenuItem=new ContextMenuItem(“Sort”);
newContextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,fnSortSelect);
newContextMenu.customItems.push(newContextMenuItem);
return newContextMenu;
}

now assign it to DataGrid.
dg.contextMenu=fnDgContextMenu(); // here dg is the “id” of the DataGrid.check the code below.

[showmyads]

Download code.

Enjoy the post.

Advertisements

One Response to Assign a menu item(on right click menu list) to DataGrid control in Flex.

  1. […] Assign a menu item(on right click menu list) to DataGrid control in Flex. « flex on blog – by kum… flexonblog.wordpress.com/2009/10/09/assign-a-menu-itemon-right-click-menu-list-to-datagrid-control-in-flex – view page – cached Assign a menu item(on right click menu list) to DataGrid control in Flex. — From the page […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: