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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 29.01.2010, 18:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Kashperuk Ivan: Lookup form returning more than one value
Источник: http://kashperuk.blogspot.com/2010/0...-than-one.html
==============

I have been posted with the question of creating a lookup that would return more than 1 value into the calling record, filling in a number of fields and populating the selected control with the corresponding value at the same time.

I will try to answer that question by an example from the standard application, particularly using one of the forms owned by my (Inventory) team.

Example


If we take a look at the lookup form for one of the item inventory dimensions (Configuration, Size or Color), we'll see the following tab page on it:
(assuming more than 1 item dimension is enabled for this item)



Basically, the user is able to select the configuration that belongs to a specific dimension combination. Note the check-box "" under the grid. If the user sets that check-box and then selects the configuration from a combination, the values for all item dimensions will be copied to the record from the parent form.
So, basically, the lookup returns more than just the configuration dimension value, but also size and color.

How is that implemented?


The lookup is implemented using a custom form, present in AOT, with name ConfigIdLookup.

The methods important for a working lookup are:
  • init() method.
In particular, the way the calling control is determined based on the args passed into the form:

callerControl = SysTableLookup::getCallerStringControl(element.args());
  • selectMode() method.
(called from setSelectMode() on this form). This method accepts an AX form control as parameter, and informs the kernel about which control should be used as the returning control.
  • closeSelect() method.
This method is executed on lookup forms wheneven a selection of a particular value is made. So, obviously, in this method you still have access you all the fields of the datasource with the selected record, as well as to the calling form through element.args(). Here is the code that handles the update of multiple fields:

if (ctrlTabPageCombination.visible() &&
selectAllCombi &&
ctrlTabPageCombination.isActivePage())
{
// Genericly determine the InventDim datasource on the calling form
callerInventDimDS = inventDimFormSetup.callerInventDimFormDatasource();
if (callerInventDimDS)
{
//...
// Get the current record of that datasource
callerInventDim = callerInventDimDS.cursor();
// Set the needed fields on the record based on the selection in the lookup form
// Basically, this is how you can achieve returning more than one value from a lookup
// Get the record where the values need to be put in, and put them in from the currently selected record
if (inventDimCombination_ConfigId.visible() && inventDimCombination.ConfigId)
callerInventDim.ConfigId = inventDimCombination.ConfigId;
if (inventDimCombination_InventSizeId.visible() && inventDimCombination.InventSizeId)
callerInventDim.InventSizeId = inventDimCombination.InventSizeId;
if (inventDimCombination_InventColorId.visible() && inventDimCombination.InventColorId)
callerInventDim.InventColorId = inventDimCombination.InventColorId;
// Refresh the datasource so that values are displayed on the calling form
callerInventDimDS.refresh();
}
}





If you want to know more

  • Spend some time investigating the existing methods on SysTableLookup class, like the method getCallerStringControl, filterLookupPreRun_DS, filterLookupPostRun.
  • Look at the methods in InventDimCtrl_Frm_Lookup class. They handle all the logic of looking up inventory dimensions, and contain some nice examples of traversing the calling object.
  • Investigate, how the lookup form described above prevents the closing of the form when the check-boxes are clicked or tab pages changed. Hint: take a look at the sage of canSelect form variable



Источник: http://kashperuk.blogspot.com/2010/0...-than-one.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Kashperuk Ivan: Lookup methods tutorial + custom list lookup implementation Blog bot DAX Blogs 0 04.05.2009 14:05
gatesasbait: How to define a custom lookup form for an extended datatype Blog bot DAX Blogs 0 09.07.2008 22:05
Kashperuk Ivan: (DAX 3.0) SysExportDialog form extension Blog bot DAX Blogs 1 15.05.2007 19:16
Kashperuk Ivan: Dynamics AX Tutorials - Tutorial 2 - Classes\Box Blog bot DAX Blogs 0 25.04.2007 22:23
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43
Опции темы Поиск в этой теме
Поиск в этой теме:

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

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

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

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