[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Custom lookup in dialogs

frango

11/22/2005 4:51:00 PM

Hi,

Looking on technet, I saw many requests to filter lookups on dialogFields
built by code (the filter depends upon another dialodField of the dialog).
The solution given is : use Forms!

I think I found another solution using Dialogs:

- Create a lookup form (see an example : tutorial_AuctionCategoryLookUp)
- Create a MenuItem::Display pointing to the new lookup form
- Duplicate the EDT (on which you want to perform the lookup).
- In the property FormHelp, select the newly created MenuItem
- In the code building the dialog (lookup of dlgField2 depends upon value
selected in dlgField1)

Dialog dlg = new Dialog("Test lookup");
dialogField dlgField1, dlgField2;
str controlName;
;

dlgField1 = dlg.addField(typeid(type1));
dlgField2 = dlg.addField(typeid(type2)); // USE HERE NEW EDT
controlName = dlgField1.name();

if(dlg.run())
...

Debug this code to see the content of controlName (in my case it is
something like "Fld1_1").

Go back to your lookup form, and use the string to indentify the control:

void init()
{
Dialog callerDlg;
FormStringControl dlgField;
;

callerDlg = element.args().caller().dialog();
dlgField = callerDlg.formRun().design().controlName("Fld1_1");
selectionText = dlgField.text();

super();
element.selectMode(...);
}

When performing the lookup on dlgField2, you now have in 'selectionText' the
value selected in dlgField1. You can use it to filter (query in
From\Datasource\init()).

François