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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 19.09.2012, 20:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
ax-erp: How to pass value from MenuItemButton to a Dialog Class?
Источник: http://microsoft-dynamics-ax-erp.blo...tembutton.html
==============


Hi everybody, as mentioned in my previos post, I will share the knowledge about dynamics AX on technical/functional perspectives. During your AX development, you will encounter different technical scenario. Although some of the scenario is able to obtain solution, but we still seeking for the best solution.



The lesson I would like to share with you is “How to pass value from MenuItemButton to a Dialog Class”. Imagine a situation you have a MenuItemButton on a form, and the MenuItemButton is calling a MenuItems (Action) and finally call the dialog class. For certain scenario, you would like to pass a value, perhaps a record, from the FORM to theDIALOG class, but you are constraint by the MenuItemButton. Possible to do it? Some of you might suggest you that MACRO can be applied here. However, apart from that, what other solution you can use?


Here, I introduce to cast the caller (mean the form) to ObjectRun type. Below are the steps that teach you how to achieve that.


Step 1: Create a dialog class, call it as MyDialogClass and extend from RunBase. In the classDeclaration part, declare a global variable, objRun, type ObjectRun. Please see picture in the galery (Step1.jpg).

Step2: Declare a method to initialize the objRun create in Step 1. Here, I call it as initObject method with an input parameter Args. Please see Step2.jpg.
void initObject(Args args)
{
objRun = _args.caller();
}
void initObject(Args args)
{
objRun = _args.caller();
}

Step 3: Overwrite the dialog method. The code are like following. For details, you can refer to Step3.jpg.
protected Object dialog()
{
DialogRunBase dialog = super();
;
dialog.addText(“Output: ” + objRun.args().parm());
return dialog;
}

Step 4: Create a main method for the class. The code is like following. Please refer to Step4.jpg as well. After finish the develop the class, please create an MenuItem, with an Action type.
public static void main(Args _args)
{
MyDialogClass dlgCls = new MyDialogClass();
dlgCls.initObject(_args);
dlgCls.prompt();
}

Step 5: This is last step. Create a form, here I named it as MyInputForm. In the form, add a StaticText and MenuButtonItem. The StaticText (I named it as Input1) which used for us to enter the value we want to pass to the dialog class. For the details, please refer to Step5.jpg. Remember to associate the MenuButtonItem with the MenuItem create on step 4 in order when you click on the button, it will call the class. For the MenuButtonItem, overwrite the clicked event. The following code should allocate under this method:
void clicked()
{
element.args().parm(input1.valueStr());
super();
}

After complete step 5, compile all the code and you can having a test. Enter some of text into the input and click the MenuItemButton, you will able see the your input appear on the dialog. Hope this lesson will benefit you.




Источник: http://microsoft-dynamics-ax-erp.blo...tembutton.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
ax-erp: Pass Query from dialog to Form and Filter records Blog bot DAX Blogs 0 18.09.2012 18:11
ax-erp: Delete lines from purch line table based on specific criteria Blog bot DAX Blogs 2 26.07.2012 00:32
daxdilip: How to Read email and download attachment from AX (AOS) without Installing Outlook Client and using EWS Exchange Web Services Blog bot DAX Blogs 0 11.12.2010 13:11
Kashperuk Ivan: Running a class from AOT or "How to assign a class to an action menu item?" Blog bot DAX Blogs 0 22.10.2009 20:05
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:56.