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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.12.2021, 22:23   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Multiple enum values selection in forms and tables
Источник: http://alexvoy.blogspot.com/2021/12/...-in-forms.html
==============

Previously I posted three supporting functions to work with multiple enum values selection. Now, let's see how they can be used in real scenarios.

With these functions you can easily expose enum values in selection lists and then save the user selection in tables.


Enum lists in a form


Check first how to show two grids in a form; so that the user could move enum values from one to another.






[Form]
public class SysPolicyTypesOneCompanyActiveOnly extends FormRun
{

private Map policyTypes = wzhTest::createMapForEnum(enumStr(SysPolicyTypeEnum));
private SysPolicyTypeEnum type;

private void resetSysPolicyTypeListPanel()
{
SysPolicyTypeAvailableGrid.deleteRows(0, SysPolicyTypeAvailableGrid.rows());
SysPolicyTypeEnabledGrid.deleteRows(0, SysPolicyTypeEnabledGrid.rows());

var mapEnumerator = policyTypes.getEnumerator();
while (mapEnumerator.moveNext())
{
type = mapEnumerator.currentKey();

if (SysPolicyTypesOneCompanyActiveOnly::exist(type))
{
this.addRowForTypes(SysPolicyTypeEnabledGrid, type);
}
else
{
this.addRowForTypes(SysPolicyTypeAvailableGrid, type);
}
}

SysPolicyTypeAvailableGrid.row(SysPolicyTypeAvailableGrid.rows() ? 1 : 0);
SysPolicyTypeEnabledGrid.row(SysPolicyTypeEnabledGrid.rows() ? 1 : 0);
}

private int addRowForTypes(FormTableControl _table, SysPolicyTypeEnum _type)
{
int i;
// Insert it into the data set in sorted order.
for (i = _table.rows(); i >= 1; i--)
{
SysPolicyTypeEnum typeIdTmp = _table.cell(1, i).data();

if (strCmp(enum2Str(typeIdTmp), enum2Str(_type)) < 0)
{
// We need to insert after the current item.
break;
}
}

// Insert the new item, i is equal to the index of the item we need to insert after.
_table.insertRows(i, 1);
_table.cell(1, i + 1).data(_type);

return i + 1;
}
...}




Multiple enum values in a table

In order to save user's selection of particular Enum values in a table, you can add a string type field there.

The rest is to convert these selected values from string to a list or a container to present them in a form.

Say, we need to let the user to select particular FiscalPeriodStatus values.







First, we add a new string field FiscalPeriodStatusSelection to our table.





We can show the currently saved selection via a display method

///
/// Returns Fiscal period statuses string values
///
/// container
/// string values of selected period statuses
[SysClientCacheDataMethodAttribute(true)]
public display LedgerExchAdjFiscalPeriodStatusSelection fiscalPeriodStatusSelectionDisp()
{
return wzhTest::enumValuesStr2EnumStrStr(this.FiscalPeriodStatusSelection, enumName2Id(enumStr(FiscalPeriodStatus)));
}





And updates this field via AnotherClass which treats the user's selection (in a form, for example)

this.FiscalPeriodStatusSelection = con2Str(AnotherClass.getFiscalPeriodStatusSelectionCont(), wzhTest::ContSeparator);

///
/// Gets FiscalPeriodStatus selection as a container
///
/// container
public container getFiscalPeriodStatusSelectionCont()
{
container cont;

while (...)
{
cont += SomeBufferOrList.FiscalPeriodStatus;
}

return cont;
}






Источник: http://alexvoy.blogspot.com/2021/12/...-in-forms.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: SEPA affected objects Blog bot DAX Blogs 0 29.11.2013 13:11
axhelper: Working with Temporary Tables in forms Reports and Runtime Blog bot DAX Blogs 0 29.09.2010 12:05
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
Kashperuk Ivan: SysMultiTableLoookup - dynamic lookups based on multiple tables Blog bot DAX Blogs 11 16.10.2008 12:26
wiki.dynamicsbook: Changes Made in Navision Attain 3.60 Blog bot Dynamics CRM: Blogs 0 02.09.2008 13:23

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

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

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