AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 25.06.2010, 02:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,487 / 846 (79) +++++++
Регистрация: 28.10.2006
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, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 17:34.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.