25.06.2010, 02:05
|
#1
|
Участник
|
paruvella: Adding Submenu and MenuItems to Ax-Menus using X++ code
Источник: http://paruvella.spaces.live.com/Blo...4DB0!540.entry
==============
In this example I am going to illustrate how we can add the Menu items to the Menu’s using X++ code.
For this example, I am using form called InventParameters.
For this form I am creating new Display Menu Item, and the same menu item I am going to place in Invent menu.
Inventory Management à Setup à My Menus à My Invent Parameters
The above marked Submenu and Menu item are added to Invent Menu by using following X++ job.
static void AddSubmenuNItemstoMenu(Args _args)
{
#AOT
TreeNode treeMenuItem;
TreeNode treeDisplayMenu;
TreeNode treeMenus;
Menu treeMenu, treeMenu1, treeMenu2;
str MenuName = "MyInventParameters";
MenuFunction menuFunction;
;
treeMenuItem = TreeNode::findNode(#MenuItemsDisplayPath);
treeDisplayMenu = TreeNode::findNode(#MenuItemsDisplayPath + "\\" + MenuName);
treeMenus = TreeNode::findNode(#MenusPath);
if(!treeDisplayMenu)
{
treeMenuItem.AOTadd(MenuName);
treeDisplayMenu = treeMenuItem.AOTfindChild(MenuName);
treeDisplayMenu.AOTsetProperties("PROPERTIES\n Object #" + "InventParameters" + "\n Label #" + "My Invent Parameters" + "\n ENDPROPERTIES\n");
treeDisplayMenu.AOTsave();
treeMenu = treeMenus.AOTfindChild("Invent");
treeMenu1 = treeMenu.AOTfindChild("Setup");
//treeMenu2 = treeMenu1.AOTfindChild("Parameters");
menuFunction = new MenuFunction(MenuName, MenuItemType::Display);
treeMenu1.addSeparator();
treeMenu1.addSubmenu("My Menus");
treeMenu2 = treeMenu1.AOTfindChild("My Menus");
treeMenu2.addMenuitem(menuFunction);
treeMenu.AOTsave();
print "New Menuitem is created under Invent menu";
pause;
}
}
In the above example I had used Menu class, instead of Treenode class for adding the Submenu and Menu items to the Menus of Ax.
After the above job is executed, you can find a new Display Menu Item at the following path
AOT à Menu Items à Display à MyInventParameters.
We can observe new Sub menu and Menu Item under Invent Menu also.
AOT à Menus à Invent à Setup à My Menus à My Invent Parameters.
 ...... 
Источник: http://paruvella.spaces.live.com/Blo...4DB0!540.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|
|