This topic is locked

Using Runner.Dialog in a Custom Button

7/21/2023 1:48:30 PM
PHPRunner Tips and Tricks
H
Henny Sol author

According to the Help when using a Runner.Dialog in a custom Button I should use "ctrl.Dialog". In other Java events I should use "Runner.Dialog".
The example in the Help (choosing a favourite colour) worked fine, but I wanted to populate the combobox from a table in my project.
Then I found that using "ctrl.Dialog" didnot work. Only "Runner.dialog" worked. Only then the dialog I defined showed. And I also had to fill my params array explicitly in the beforeOK and I also had to add the submit command (much thanks to Corrie) to pass the variables of the Dialog to the Server event.
This really amazed me. So in the end I had to define my Dialog in my CustomButton events in exactly the same way I had to do it -according to the Help- in the "other Java events".
It seems something has changed & the Help is not aware of this change. Or am I missing something?
My current build is 41053.
Best regards!
Henny Sol

Sergey Kornilov admin 7/21/2023

Without seeing your exact code and an explanation of what "didn't work", there is nothing that we can do here.
If your question is "what has changed lately in regards to dialogs" - nothing really changed recently.

H
Henny Sol author 7/22/2023

I added a custom Button outside the grid of a List page and added the sample Dialog code from the help to the ClientBefore event of the button:
return ctrl.Dialog( {
title: 'Preferences',
fields: [{
name: 'color',
type: 'lookup',
value: 2,
options:

[
[1,'red'],
[2,'green'],
[3,'yellow']
]
}],
ok: 'Save',
cancel: 'Cancel',
beforeOK: function( popup, controls ) {
swal('Success', 'Selected color: ' + controls[0].val(), 'success');
}
});
return false;
Clicking the Button nothing happens. When I change ctrl.Dialog to Runner.Dialog the dialog works fine. But the color field is not sent automatically to the Server event; I have to fill the params array explicitly AND execute the submit() commnad to send the params array to the Server event. After changing the beforeOK lines to the following the dialog works fine. This really differs from what is stated in the Help concerning building dialogues.
beforeOK: function( popup, controls ) {
// swal('Success', 'Selected color: ' + controls[0].val(), 'success');
params["color"]=controls[0].val();
submit();
}
});