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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 15.06.2011, 03:25   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Preston.Larimer: Adding a custom lookup to a form control
Источник: http://palarimer.greenlight2go.com/2...m-control.html
==============



In Dynamics AX one way you can add a custom lookup or drop down list to a form control by overriding the lookup method of the control. Below is some example code for doing this.

X++:
public void lookup() 

 { 

     //This lookup basis the list criteria on information in 2 tables

     //All display fields come from Table1, Table2 is used for limiting criteria

     

     //super(); 

     

     //This Next Line initializes the the sysTableLookupClass

     sysTableLookup          sysTableLookup  =

                     SysTableLookup::newParameters(tableNum(<TABLENAME1>), this); 

     

     Query                   query           = New Query(); 

     QueryBuildDataSource    qbdsTbl1, qbdsTbl2; 

     QueryBuildRange         qbr; 

     ; 

     

     //Add Tables to the data source

     qbdsTbl1      = query.addDataSource(tableNum(<TABLENAME1>)); 

     qbdsTbl2     = qbdsTbl1.addDataSource(tableNum(TABLENAME2)); 

  

  

     //Add Query Ranges to limit List records     

     qbr = qbdsTbl1.addRange(fieldNum(<TABLENAME1>,<RANGEFIELDNAME1>)); 

     qbr.value(<CRITERIAVALUE>); 

  

     qbr = qbdsTbl1.addRange(fieldNum(<TABLENAME1>, <RANGEFIELDNAME2>)); 

     qbr.value(<CRITERIAVALUE>); 

  

     qbr = qbdsTbl1.addRange(fieldNum(<TABLENAME1>, <RANGEFIELDNAME3>)); 

     qbr.value(<CRITERIAVALUE>); 

     

     //Since we have multiple tables in the query turn on relations

     qbdsTbl1.relations(true); 

  

     //Add Ranges to the Table2

     qbr = qbdsTbl2.addRange(fieldNum(<TABLENAME2>, <RANGEFIELDNAME4>)); 

     qbr.value(<CRITERIAVALUE>); 

     

     qbdsTbl2.relations(true); 

  

     //The next 2 lines actualy adds the fields that will be displayed in the lookup grid

     sysTableLookup.addLookupfield(fieldNum(<TABLENAME1>, <DISPLAYFIELDNAME>)); 

     sysTableLookup.addLookupfield(fieldNum(<TABLENAME1>, <DISPLAYFIELDNAME>)); 

     

     //Hand the created query to the sysTableLookupClass

     sysTableLookup.parmQuery(query); 

  

     //Display the drop down 

     sysTableLookup.performFormLookup(); 

  

 }
Another example single table with field and table names instead of variable place holders
X++:
//Single table example with actual table and field names instead of  place holders

 public void lookup() 

 { 

     //This lookup basis the list criteria on information in 2 tables

     //super(); 

     sysTableLookup          sysTableLookup  = 

                 SysTableLookup::newParameters(tableNum(salesBillOfLadingJournalTable), this); 

     Query                   query           = New Query(); 

     QueryBuildDataSource    qbdsJT, qbdsBLR; 

     QueryBuildRange         qbr; 

     ; 

  

     qbdsJT      = query.addDataSource(tableNum(salesBillOfLadingJournalTable)); 

     qbdsBLR     = qbdsJT.addDataSource(tableNum(salesBLReservation)); 

  

  

  

     qbr = qbdsJT.addRange(fieldNum(salesBillOfLadingJournalTable,isMaster)); 

     qbr.value(enum2str(noYes::No)); 

  

     qbr = qbdsJT.addRange(fieldNum(salesBillOfLadingJournalTable, custAccount)); 

     qbr.value((salesBillOfLadingJournalTableMaster.CustAccount)); 

  

     qbr = qbdsJT.addRange(fieldNum(salesBillOfLadingJournalTable, masterBLID)); 

     qbr.value(&quot;&quot;&quot;&quot;); 

  

     qbdsJT.relations(true); 

  

     qbr = qbdsBLR.addRange(fieldNum(salesBLReservation, blOpen)); 

     qbr.value(enum2str(noYes::Yes)); 

     qbdsBLR.relations(true); 

  

     sysTableLookup.addLookupfield(fieldNum(salesBillOfLadingJournalTable, BillOfLadingID)); 

     sysTableLookup.addLookupfield(fieldNum(salesBillOfLadingJournalTable, salesID)); 

     sysTableLookup.parmQuery(query); 

  

     sysTableLookup.performFormLookup(); 

  

 }



Источник: http://palarimer.greenlight2go.com/2...m-control.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 15.06.2011 в 09:42. Причина: оформление
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Microsoft Dynamics CRM Team Blog: How to control surfacing of Custom Activity Blog bot Dynamics CRM: Blogs 0 17.05.2011 01:14
axhelper: To add lookup in form control Blog bot DAX Blogs 0 08.10.2010 14: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: Lookup form returning more than one value Blog bot DAX Blogs 0 29.01.2010 18:05
gatesasbait: How to define a custom lookup form for an extended datatype Blog bot DAX Blogs 0 09.07.2008 22:05

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

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

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