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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 19.06.2018, 11:11   #1  
Blog bot is offline
Blog bot
Участник
 
20,694 / 713 (65) +++++++
Регистрация: 28.10.2006
sunilrakesh: Treeview lookup in D365FO
Источник: https://community.dynamics.com/membe...d-4e6c628498d3
==============

Tree view lookups are not new but out of the box it made with EDT relations in earlier versions, but in D365FO EDT relations are deprecated, instead we can achieve through table references, here is a small example with steps. My requirement is like getting tree as an lookup in a ParentId field.

1. Create a table with relation as shown:
OperatingareaId field is my tree node trying to get lookup in ParentID field.



2. Create EDT for OperatingAreaId and give table reference of your table as show:
and give OperatingAreaId as reference & Formhelp with lookup form which we created down.



3. For ParentId field extend the EDT of OperatingAreaId and put table reference eith table name and give OperatingareaId as table reference.













1. Create a form lookup as shown above with datasource and with form tree control.
2. In run() method use your tree view class.
In this form we use tree class.(find existing class and build your own logic eg. Class smmSalesUnitTree)
sample code of form methods:[Form]

public class SupOperatingAreaLookup extends FormRun

{
SupplierOperatingAreaTree operatingAreaTree;

void exit()
{
int selection;
FormTreeItem formTreeItem;


selection = OperatingAreaTreeCtl.getSelection();
formTreeItem = OperatingAreaTreeCtl.getItem(selection);


if (formTreeItem && selection != OperatingAreaTreeCtl.getRoot())
{
element.closeSelect(formTreeItem.data());
}
}
public void run()

{
str selectedValue = "";


operatingAreaTree = new SupplierOperatingAreaTree(SupplierOperatingArea_ds, OperatingAreaTreeCtl,

fieldNum(SupplierOperatingArea, OperatingAreaId),

fieldNum(SupplierOperatingArea, ParentId),

fieldNum(SupplierOperatingArea, Description),

false);


if (element.args() && element.args().dataset())
{
FormStringControl callerControl = SysTableLookup::getCallerStringControl(element.args());
selectedValue = callerControl.text();
}


if (selectedValue)
{
SupplierOperatingArea supOpeArea = SupplierOperatingArea::find(selectedValue);

operatingAreaTree.initRoot("Operating area", supOpeArea.RecId);
operatingAreaTree.expandAndSelect(supOpeArea);
}
else
{
operatingAreaTree.initRoot("Operating area", '');
}


super();
}
int task(int p1)
{
#Task


int ret;


ret = super(p1);


if (p1 == #taskEnter)
{
element.exit();
}


return ret;
}
[DataSource]
class SupplierOperatingArea
{
public void init()
{
super();
this.addFieldToSelectionList(fieldNum(SupplierOperatingArea,OperatingAreaId));

this.addFieldToSelectionList(fieldNum(SupplierOperatingArea, ParentId));

this.addFieldToSelectionList(fieldNum(SupplierOperatingArea, Description));

}
public void executeQuery()
{
super();
operatingAreaTree.selectDatasource();

}
}
[Control("Tree")]
class OperatingAreaTreeCtl
{
public boolean expanding(int _idx, FormTreeExpand _action, anytype _data)
{
boolean ret;
ret = super(_idx, _action, _data);
operatingAreaTree.expanding(_idx, _action, _data);

return ret;
}
public void selectionChanged(FormTreeItem _oldItem, FormTreeItem _newItem, FormTreeSelect _how)
{
super(_oldItem, _newItem, _how);
operatingAreaTree.selectionChanged(_oldItem, _newItem);
if (_how == FormTreeSelect::ByMouse)
{
element.exit();
}

}
}
}









Источник: https://community.dynamics.com/membe...d-4e6c628498d3
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
sunilrakesh: Export file from D365FO to OneDrive using LogicApp Blog bot DAX Blogs 0 04.02.2018 17:15
sunilrakesh: Lookup on filed based on selected BaseEnum element in another field. Blog bot DAX Blogs 0 31.05.2017 17:11
sunilrakesh: Reference group lookup in D365 (Ax7) Blog bot DAX Blogs 0 31.05.2017 17:11
Microsoft Dynamics CRM Team Blog: What’s new in the Lookup control with Microsoft Dynamics CRM 2013 Blog bot Dynamics CRM: Blogs 0 04.12.2013 04:13
Microsoft CRM: CRM 2011 TreeView for Lookup Blog bot Dynamics CRM: Blogs 0 14.12.2011 18:11
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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