Hi,
I am creating a report script with a dialogue using drop list boxes. I want the user to be able to select different sales areas as input to the report. Depending on the selection, in the same dialogue I want to offer a second selection to refine the scope.
For instance, if the first drop list box holds two options - "European sales" and "Asias sales" - and the user select "European sales", then the second drop list box should read its contents from an array where the European salses offices are listed. For instance "Denmark","Germany","UK",...
I was first looking at "setDlgListBoxArray" as a candidate to achieve this, but it doesn't seem to be doing what I am looking for here.
Have anybody out there tried this before? A helpful hint to the right direction would be appreciated.
/ Harry
Hi,
First I build two lists (arrays) with countries, one with European countries and one with Asian countries. These are later to be used as values for the drop list boxes. The names of these arrays are "sEuropean_Country_list" and "sAsian_Country_list".
Then the dialogue code looks like this:
// Dialogue begin--------------------------------------------------------------------------------- var userdialog = Dialogs.createNewDialogTemplate(0, 0, 440, 145, "View selection"); userdialog.Text(10, 10, 400, 15, "Select the items you want to follow"); userdialog.Text(10, 25, 400, 15, "Click on OK to finish the report"); userdialog.GroupBox(7, 55, 426, 55, "Select region"); // First list box option is picked here: userdialog.DropListBox(20, 70, 360, 15, ["European sales","Asian sales"], "sRegion"); userdialog.GroupBox(7, 120, 426, 55, "Select country"); // Second list box options, depending on the selection made in the first list box userdialog.setDlgListBoxArray ("sRegion" , ???); // userdialog.DropListBox(20, 135, 360, 15, sCountry_list, "sSelectedItem"); userdialog.OKButton(); userdialog.CancelButton(); var dlg = Dialogs.createUserDialog(userdialog); nuserdialog = __toLong(Dialogs.show( __currentDialog = dlg)); // Displays dialog and waits for the confirmation with OK. // End Dialogue ---------------------------------------------------------------------------------
What I am trying to figure out is what goes in setDlgListBoxArray instead of "???" and what more is possibly missing.
Regards / Harry
Hi Harry,
look into help, function createNewDialogTemplate ( int X, int Y, int DX, int DY, String Title, String sDialogFunc ). Use last parameter - sDialogFunc. This function catchs events.
So try use my example
function main(){ var userdialog = Dialogs.createNewDialogTemplate(0, 0, 440, 145, "View selection", "dlgFuncOutputOptions"); userdialog.Text(10, 10, 400, 15, "Select the items you want to follow"); userdialog.Text(10, 25, 400, 15, "Click on OK to finish the report"); userdialog.GroupBox(7, 55, 426, 55, "Select region"); // First list box option is picked here: userdialog.DropListBox(20, 70, 360, 15, [" ", "European sales","Asian sales"], "sRegion"); userdialog.GroupBox(7, 120, 426, 55, "Select country"); // Second list box options, depending on the selection made in the first list box //userdialog.setDlgListBoxArray ("sRegion" , ???); userdialog.DropListBox(20, 135, 360, 15, new Array(), "sSelectedItem"); userdialog.OKButton(); userdialog.CancelButton(); dlg = Dialogs.createUserDialog(userdialog); nuserdialog = Dialogs.show( __currentDialog = dlg); } function dlgFuncOutputOptions(dlgItem, act, suppVal) { var bResult = true; switch(act) { case 1: // dialog initialization dlg.setDlgValue("sRegion", 0); bResult = false; break; case 2: if (dlgItem == "sRegion"){ if (suppVal == 1) // European sales var aCountry = new Array("Slovakia", "Austria", "Russia", act); else if (suppVal == 2) // Asian sales var aCountry = new Array("China", "India"); else var aCountry = new Array(); dlg.setDlgListBoxArray("sSelectedItem", aCountry); } bResult = false; break; } return bResult; } main();