Hey guys,
I want to create a reset button, that reset all inputs from the user. (should actually be no problem)
But i get some issues with: this.dialog.getPage(0).getDialogElement("COMBO_LANGUAGE").setSelection(0)
I don´t know why, but when I want to set the selection of a combobox, Aris doesn´t want to change the selection.
I want to set the selection to index 0 and then make the combobox setEnabled(false).
But the only thing what aris does, is to set the combox enabled(false) but not to set the selection to index 0.
But, when I print the current getSelection() of the combobox I get the value of index 0, so it seems that Aris doesn´t update the dialog view ...
Is there a way to refresh/update the window?
Thanks!!
The code:
this.OPTIONGROUP_selChanged = function() {
(...)
if (this.dialog.getPage(0).getDialogElement("OPTIONGROUP").getSelectedIndex() == 1) {
this.dialog.getPage(0).getDialogElement("COMBO_LANGUAGE").setEnabled(true);
(...)
} else{
this.dialog.getPage(0).getDialogElement("COMBO_LANGUAGE").setSelection(0);
if(this.dialog.getPage(0).getDialogElement("COMBO_LANGUAGE").isEnabled()){
this.dialog.getPage(0).getDialogElement("COMBO_LANGUAGE").setEnabled(false);
}
(...)
}
Could you describe the problem by describing the setup, and which steps to undertake to reproduce the unexpected behavior? E.g. you allow the string values x, y and z to be selected in the combobox when you create the combobox, then you start the macro and set the combobox to value y and when you trigger the reset the combobox value is set to x and the combobox gets disabled.
Just asking because I have a hard time reproducing your problem. I admittedly used a Report script instead of a Macro, but with Dialogs working the same in both (only how they are shown is different) this shouldn't be a huge issue:
Dialogs.showDialog(new myDialog(), Constants.DIALOG_TYPE_ACTION, "Just a test") function myDialog(){ this.getPages = function() { var iDialogTemplate1 = Dialogs.createNewDialogTemplate(600, 300, "First page"); iDialogTemplate1.PushButton(15, 20, 40, 30, "Test", "PB1"); iDialogTemplate1.ComboBox(15, 80, 70, 30, ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6"], "CB1"); return [iDialogTemplate1]; } this.PB1_pressed = function(){ this.dialog.getDialogElement("CB1").setSelection(0); if(this.dialog.getDialogElement("CB1").isEnabled()){ this.dialog.getDialogElement("CB1").setEnabled(false); } else { this.dialog.getDialogElement("CB1").setEnabled(true); } } }
I can start the report and a dialog is shown, I can set the value of the combo-box to "Test 4", and when I press the button it resets the combobox-value to "Test 1" and disables the combo-box. Pressing the button again re-enables the combobox and I can set another value again, press the button and it resets the value to "Test 1" and disables the combobox, just as expected.
Maybe I found a solution for my strange problem... It works but it is not so nice.
The function isInValidState() is called each time a dialog value is changed by the user, so with help the var resetModus I can change the selection of the combobox... idk why it only works this way.
Dialogs.showDialog(new myDialog(), Constants.DIALOG_TYPE_ACTION, "Just a test") var resetModus = 0; function myDialog(){ this.getPages = function() { var iDialogTemplate1 = Dialogs.createNewDialogTemplate(600, 300, "First page"); iDialogTemplate1.PushButton(15, 20, 40, 30, "Test", "PB1"); iDialogTemplate1.ComboBox(15, 80, 70, 30, ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6"], "CB1"); return [iDialogTemplate1]; } this.PB1_pressed = function(){ resetModus = 1; if(this.dialog.getDialogElement("CB1").isEnabled()){ this.dialog.getDialogElement("CB1").setEnabled(false); } else { this.dialog.getDialogElement("CB1").setEnabled(true); } } this.isInValidState = function(pageNumber) { if(resetModus==1){ this.dialog.getDialogElement("CB1").setSelection(0); } resetModus = 0; } }
Glad to hear that you found a solution. Strange that setSelection doesn't work in the _pressed reaction-function, but does work in the isInValidState function.
For future reference, may I ask which ARIS version you are using? The version I'm using (where setSelection does work in the reaction method) is version 10.0.3.
Also just a side note: the return value of setSelection is not described in my version of the ArisScript help, but the method does return a boolean true for me. Maybe that's if the selection was successfully changed? Does it return anything for you? just place a "text" somewhere in your dialog and save the return value of setSelection to a variable, then set the text of the "Text" to the value of the variable.