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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 06.11.2014, 08:14   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
Dialog field with multiple choice
Источник: http://alexvoy.blogspot.com/2014/11/...le-choice.html
==============

<div dir="ltr" style="text-align: left;" trbidi="on">
This is a small tutorial class on how to work with the new AX 2012 SysLookupMultiSelectCtrl class.

There are good examples on the internet as well as a tutorial class in AX 2012 itself but I want to explain how to pack/unpack values for this field and make it mandatory.

Let's say we need to select multiple sites in the dialog.





I hope my comments inline will be enough. If not let me know, please.


class tmxMultiSelectSiteTutorial extends RunBase
{
FormBuildStringControl fbscMultiSite;
FormStringControl fscMultiSite;
container siteIds;
str siteIdsStr;

SysLookupMultiSelectCtrl multiSiteCtrl;
DialogRunbase dialog;

#define.CurrentVersion(1)
#define.Version1(1)
#localmacro.CurrentList
siteIdsStr
#endmacro
}

protected Object dialog()
{
dialog = super();
// add a new form build control for multiple choice; string type
fbscMultiSite = dialog.curFormGroup().addControl(FormControlType::String, identifierstr(AnyFormControlNameYouLike));
fbscMultiSite.label('Site');

return dialog;
}

public void dialogPostRun(DialogRunbase _dialog)
{
FormRun formRun;

super(dialog);

formRun = _dialog.dialogForm().formRun();

if (formRun)
{
// to get the access to the form control we created on the dialog
fscMultiSite = formRun.design().control(fbscMultiSite.id());
// create multiple loookup of SysLookupMultiSelectCtrl type
// cgiInventSite query must exist in AOT; simply SiteId and Name from InventSite table
multiSiteCtrl = SysLookupMultiSelectCtrl::construct(formRun, fscMultiSite, querystr(cgiInventSite));
// to underline it red; actually it does not validate; so check the Validate method
multiSiteCtrl.setMandatory(true);
// if we restored from last values
if(siteIdsStr)
{
//then we convert the string to container
siteIds = str2con(siteIdsStr);
// after create the special container of SiteIds and Names
multiSiteCtrl.set(this.siteIds2Names(siteIds));
}
}
}

public boolean getFromDialog()
{
if (multiSiteCtrl)
{
// selected sites convert to container of RecIds
siteIds = multiSiteCtrl.get();
// convert it to string for pack/unpack
siteIdsStr = con2Str(siteIds);
}
return super();
}

private container siteIds2Names(container _c)
{
InventSite inventSite;
container contSiteId, contRecId;
int i, cLen = conLen(_c);

for (i = 1 ; i
public void run()
{
InventSite inventSite;
int i;
int conNum = conLen(siteIds);

// any business logic for the selected sites
for( i = 1; i
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Bug: One character in dialog field label causes wrong redrawing Blog bot DAX Blogs 0 24.01.2014 01:15
axtadka: Adding a field on dialog by addfield() method, when the type of EDT is known at run time, in Dynamics AX 2009 Blog bot DAX Blogs 0 17.11.2012 11:12
Microsoft Dynamics CRM Team Blog: Welcome to the World of Dialogs - Part 1 Blog bot Dynamics CRM: Blogs 0 02.02.2011 21:11
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05

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

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

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