I have seen answers for capturing events from user-created controls on wizard pages, but how do you do it for controls created as a result of a call to CreateInputOptionPage?
For example:
InputOptionPage := CreateInputOptionPage (wpWelcome,
'Options',
'Select your option',
'Please choose from one of the three options below:'
True, False);
InputOptionPage.Add ('Option 1') ;
InputOptionPage.Add ('Option 2') ;
InputOptionPage.Add ('Option 3') ;
will create an option page with a radio group on it. I don't intend selecting any of the options by default and want to force the user to do so. As a visual clue I want to gray out the "Next" button while none are selected.
How do I add an OnClick handler for the radio buttons?
Although not directly the same question, the answer I just provided to this question shows how to do this for a Check Box but it's identical for a radio box.
Short extract from Robert Love's answer:
procedure YourControlClick(Sender: TObject);
begin
MsgBox('yep', mbError, 0);
end;
YourControl.OnClick := #YourControlClick;
I.e. everything is similar to usual Delphi style except for # symbol. Omitting it results in confusing "Invalid number of parameters" error during compile.
Related
I am currently learning some very basic JS and Cypress in order to be able to write some UI test for the shiny R markdown application I am developing (very new to this!!). I have managed to write a simple test that asserts that a given value is selected by default when the app starts up. However, I would like to be able to select a specific element and more importantly, loop over the entire list of elements available in order to assert that the output is as expected.
I'm stuck figuring out how to select a specific element from the dropdown and also don't know how to implement a loop yet. Any pointers will be much appreciated!
Here is a simple shiny app that contains only a dropdown with 3 options (app.R file) as I cannot share the original code due to proprietary reasons:
library(shiny)
ui <- fluidPage(
selectizeInput(inputId = 'element1', label = "Test input",
choices = c('descriptive', 'comparative', 'neutral'),
selected = 'descriptive')
)
server <- function(input, output) {}
# Run the application
shinyApp(ui = ui, server = server)
In my simple UI test, I have managed to write the assertions similar to this:
cy.get('select#element1 option:selected')
.should('have.value', 'descriptive')
But when I use the web inspector to inspect the structure of the selectizeInput, I don't understand why the options are not listed as select options. That seems to be the reason for why I cannot use something like cy.get('select#element1').select('comparative') to select a different value from the dropdown. I thought maybe the other options were "hidden", but I then found them in a separate div further down in the DOM:
I'm really just starting to learn all of this, so any pointers would be super helpful. Even just to help me google the right things, because googling how to work with select elements in cypress was apparently not the right thing?
You can use the eq() command if you want to select any items from the dropdown:
//Click to open the dropdown
cy.get('div.option').eq(1).click() //selects comparative
You can also use a combination of text and selector using contains() and select the item from drop-down:
//Click to open the dropdown
cy.contains('div.option', 'neutral').click() //selects neutral
You can also use the filter() command:
//Click to open the dropdown
cy.get('div.option').filter(':contains("neutral")').click() //selects neutral
If you want to loop through the elements and then select you can do something like:
Using the index Position
//Click to open the dropdown
cy.get('div.option').each(($ele, index) => {
if (index == 1) {
cy.wrap($ele).eq(index).click()
}
})
Using the element text
//Click to open the dropdown
cy.get('div.option').each(($ele, index) => {
if($ele.text() == "comparative") {
cy.wrap($ele).click()
}
})
Component libraries often enhance the select control in order to give a better look, additional features like multi-select. The plain HTML5 select is limited in how you can style and control it.
In the case of Shiny library, they have added both a <select> to hold the value plus a set of nested <div> to provide the enhancements (the next element block after <select>).
The <select> has style="display: none;" which means the user cannot interact with it directly, but it is updated in the javascript event handlers.
Doing e2e tests we want interact as a user would, but test the hidden <select> value since this is what is used by the R framework.
// Test the initial value of hidden select
cy.get('select#element1')
.should('have.value', 'descriptive')
.find('option')
.should('have.length', 1) // only one option on the select
cy.get('select#e1')
.next() // access the UI block
.click() // open the "select"
.contains('comparative') // chose an option
.click()
// Test the new value of hidden select
cy.get('select#e1')
.should('have.value', 'comparative')
.find('option')
.should('have.length', 1) // still only one option
Looping
// Test the initial value of hidden select
cy.get('select#element1')
.should('have.value', 'descriptive')
.find('option')
.should('have.length', 1) // only one option on the select
const choices = ['descriptive', 'comparative', 'neutral']
choices.forEach(choice => {
cy.get('select#e1')
.next() // access the UI block
.click() // open the "select"
.contains(choice) // chose this choice
.click()
// Test the new value of hidden select
cy.get('select#e1')
.should('have.value', choice)
})
I have an array:
[
0 => 'translate.label1',
1 => 'translate.label2',
2 => 'translate.label1'
]
which I specify as a choices param for field creation.
Now, is it possible to sort these options by translated labels? For example, label1 translated value is zero, label2 - something, label3 - abracadabra. Of course, I expect select options to be:
abracadabra
something
zero
I thought to use this approach: https://stackoverflow.com/a/21586886/2324004
But doesn't it involve second translator digest inside view? Any ideas? I'd rather to use something more flexible because my form is based on non-fixed selects count and it would have executed something recursive...
You have to do it in js after data will be uploaded.
Check this topic:
Javascript to sort contents of select element
Due to fact the translation occurs inside Twig view, the only solution (right now I'm aware) is to prepare translated and sorted list during form build process by injecting manually TranslatorInterface service.
Unfortunately, without overriding widget's template, translation occurs second time, against already translated labels.
Using Domino Designer 8.5. If I have a form with a radio button field, is it possible to disable that field in LotusScript, possibly in the Postopen even of the form?
The only way I can, so far, see of achieving this is by using the Input Enabled formula of the field itself, but I am struggling to understand when this is triggered... if I try to put a #StatusBar or #Prompt formula call in there as well then there is never any notification of Input Enabled being triggered.
If Input Enabled is the way to achieve this, not LotusScript, then is there a way I can have a) a formula that sets the Input Enabled condition plus b) a way of getting some visual output, either to the Status Bar or a Message Box, to either just indicate the formula has been triggered or - even better - to let me know the value of some variable I'd like to check?
The Input Enabled Formula is triggered on every refresh of the document (F9, Save, NotesUIDocument.Refresh, etc.), it can not contain any code "interacting" with the user.
But you could do something like this:
Create a Field "InputEnabled"
The best way to have a "controlling" field is to make it "Computed for Display". That way it is not stored in the document. As a formula you simply enter #ThisValue, then it does not change its value by itself and can be set using LotusScript. If you want to have an "initial" value, then the formula would be: #If( #ThisValue = "" ; "YES" ; #ThisValue )
In the "Input enabled" Formula of your other field write the code:
InputEnabled = "YES"
Fill the "InputEnabled"- Field using a LotusScript (NotesDocument.ReplaceItemValue( "InputInabled", "YES" ), or using a Formula directly in the field.
Like that you can easily "see" what the conditions are (in the field InputEnabled) and change it using formula or script.
Old school way to Disabling the radio button field:
You will have to use the **Hide paragraph if formula is true". Define a field: MyButEnabled accorting to which you enable (show) or disable (hide) the field. for UI convience display a complementary line that only display the value of your radio button (you can also use a computed radio button but it's not very pretty).
In the post open set the appropriated value for the field MyButEnabled. Dont forget to call uidoc.RefreshHideFormulas method.
The notes input enabled way: (see also: http://www-01.ibm.com/support/docview.wss?uid=swg21173862)
the notes input enabled formula is (for example)
#if(MyButEnabled="Y" ; 1 ; 0)
When you form is openned, the formula is computed, if the result is 0 the field won't be editable, 1 will allow field to be edited.
If you change the value of MyButEnabled, then you need to make a UIdocument.refresh in order to change to be reflected in the UI.
i am using function "REUSE_ALV_GRID_DISPLAY" in order to display a grid. My problem is that not all the buttons in alv toolbar are displayed. For example, i can not see the "delete row" button.
This is my call:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = fieldcatalog
TABLES
t_outtab = lt_files_records_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
Can you please help?
IF you need the full editor functionality (including cell editors), you will have to move away from the (obsolete and unsupported) function module to the class CL_GUI_ALV_GRID. See the documentation here.
If you only need a delete button, it might be easier to add a custom button. Check the program SALV_DEMO_TABLE_FUNCTIONS for an example (and start using the ALV OM instead of the old function modules - much easier to code with).
I think this has to be THE most frustrating thing I've ever done in web forms. Yet one would think it would be the easiest of all things in the world to do. That is this:
I need 2 separate lists of radiobuttons on my .aspx page. One set allows a customer to select an option. The other set does also but for a different purpose. But only one set can have a selected radiobutton.
Ok I've tried this using 2 asp.net Radiobuttonlists controls on the same page. Got around the nasty bug with GroupName (asp.net assigns the control's uniqueID which prevents the groupname from ever working because now, 2 radiobuttonlists can't have the same groupname for all their radiobuttons because each radiobuttonlist has a different uniqueID thus the bug assigns the unique ID as the name attribute when the buttons are rendered. since the name sets are different, they are not mutually exclusive). Anyway, so I created that custom RadioButtonListcontrol and fixed that groupname problem.
But when ended up happening is when I went to put 2 instances of my new custom radiobuttonlist control on my .aspx page, all was swell until I noticed that every time I checked for radiobuttonlist1.SelectedValue or radiobuttonlist2.SelectedValue (did not matter which I was checking) the value always spit back string.empty and i was not able to figure out why (see http://forums.asp.net/t/1401117.aspx).
Ok onto the third try tonight and into the break of dawn (no sleep). I tried to instead just scrap trying to use 2 custom radiobuttonlists altogether because of that string.empty issue and try to spit out 2 sets of radiobuttonlists via using 2 asp.net repeaters and a standard input HTML tag inside. Got that working. Ok but the 2 lists still are not mutually exclusive. I can select a value in the first set of radiobuttons from repeater1 and same goes for repeater2. I cannot for the life of me get the "sets" to be mutually exclusive sets of radiobuttons.
As you have two groups of radio buttons that you want to function as one group of radio buttons, the solution is simple: Make it one group of radio buttons.
The only problem you have then is that the value that you get has the same name from both lists, but that can be solved by adding a prefix to the values so that you easily identify from which list the option comes.
Update: based on the new info posted as an answer. The option I proposed on my original answer corresponds to the 3. You really must consider the following:
Html radio buttons have only 1
built-in mechanism to handle the
exclusivity, which is the name.
You are explicitly requesting a no js solution, so given the above you must manipulate the Ids to achieve it. If you weren't blocking this option I am sure someone would come up with some nice jquery or js library that already supports it.
The option 3 is clearly the less invasive, as you are not forced to affect the actual data, and are not affected by future updates to it.
It's not that much code, just something extra on the List indexes, and some simple thing as:
int? list1Value = null;
int? list2Value = null;
var value = Request.Form["somegroup"];
if (value.StartsWith("List1"))
list1Value = int.Parse(value.Substring(5));
else
list2Value = int.Parse(value.Substring(5));//Assuming List2 as prefix
Original:
I saw your other question, and you just need to use the same group name. Make sure you have different values for all items regardless of the list they come from. A way to achieve this is adding something to the values, like: <%# "List1-" + Eval("ID") %> and modifying the code that reads your Request.Form["yourgroupname"].
I think you should just use RadioButtons instead of RadioButtonLists.
Here's an article that presents a solution to resolve the radiobutton naming bug.
Though this post is dated 1 year ago already, I just read it because I face the same problem.
Currently I have 1 solution using jQuery:
Client side script (you must also include jQuery)
function SetRadio(rb) {
$('input:checked').attr('checked', false);
rb.checked = true;
}
For every radiobutton (which is a listitem in a radiobuttonlist) I add the following on the serverside:
li.Attributes.Add("onclick", "javascript:SetRadio(this)");
For me this works in both IE and Firefox, with 3 radiobuttonlists, without using groupnames.
You can check each radiobuttonlist for a selecteditem/value, or you can extend the SetRadio function so it stores the selected value in a hidden field.
Regards,
M