Skip to main content
17-Peridot
March 29, 2023
Solved

Radio button

  • March 29, 2023
  • 2 replies
  • 2095 views

Hello,

 

I am trying to use two radio button widgets in a mashup on 9.3.5.

jensc_0-1680081588221.png

I have set them to the same Radiogroup:

jensc_1-1680081671646.png

And I feel like I am missing something super obvious, but shouldn't I be able to know which of the buttons in the group I have selected? Otherwise I'm not sure I see the reason to group them...

 

For now I'll just use the "Generic Radio Button" widget instead.

 

Thanks,

Jens

Best answer by jensc

*Explanation*

 

It seems like there are different use cases for each type of radio button widget.

 

For my particular use case it is simpler to just use the Generic Radio Button widget as I would like to use it to quickly select one or the other option in it.

For other use cases such as somewhere you would like to have a multi select (similar to check boxes) but want to limit the user in only selecting one option, then the Themable Radio Button widget might be better.

 

I hope this explanation covers most situations in case someone else stumbles upon this post.

Also, have a look at @nitinsriv answer as well.

 

Thanks,

Jens

2 replies

5-Regular Member
March 29, 2023

In case you are trying to achieve something like below:

 

nitinsriv_0-1680096394546.png

red marked is radio group, while the blue one is generic radio button.

Then I have a binding to trigger service which just displays option selected as a basic example.

But hopefully this can be extended to fit your needs with some tweaking.

nitinsriv_1-1680096490550.png

nitinsriv_2-1680096575605.png

 

 

 

 

jensc17-PeridotAuthor
17-Peridot
March 29, 2023

Hello,

 

I think I see what you have done.

Basically if the first radio button is not "true" then the second radio button would be (if you have set one of the buttons to true by default).

This approach does work, I was even thinking of having both radio buttons states passed into an expression and do a check like:

 

if (button1 && !button2) {
 output = 'button1 selected';
else if (!button1 && button2) {
 output = 'button2 selected';
}

But this would get really annoying if I need to add more buttons in the future.

 

I suppose if I don't want to use the Generic Radio Button widget I'd have to build my own widget or wait for an update of the regular "Radio button" widget.

 

Thanks,

Jens

16-Pearl
March 30, 2023

The radio group only "makes sure" that only one is active. To find out which one you are on the right track I think.

 

As an alternative you can use the "ButtonBar" which may be easier to use but needs a StateDefinition. E.g. with alert priority State definition:

nmutter_0-1680168989402.png

 

jensc17-PeridotAuthorAnswer
17-Peridot
March 31, 2023

*Explanation*

 

It seems like there are different use cases for each type of radio button widget.

 

For my particular use case it is simpler to just use the Generic Radio Button widget as I would like to use it to quickly select one or the other option in it.

For other use cases such as somewhere you would like to have a multi select (similar to check boxes) but want to limit the user in only selecting one option, then the Themable Radio Button widget might be better.

 

I hope this explanation covers most situations in case someone else stumbles upon this post.

Also, have a look at @nitinsriv answer as well.

 

Thanks,

Jens