cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

What exactly does 'radiogroup' in the beta radio button widget do?

ague
12-Amethyst

What exactly does 'radiogroup' in the beta radio button widget do?

I want to have a selection of several radio buttons. How do I use the 'radiogroup' feature to do this? For example, I just want two radio buttons, each with a label 'A' and 'B'. I have bound the radiogroup property to a service which returns two strings, but I only ever see the first one.

 

Is that what the 'radiogroup' feature will do? 

 

I have already found this article (http://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Mashup_Builder/Widgets/RadioButtonWidgetBeta.html) and it give no real explanation. 

1 ACCEPTED SOLUTION

Accepted Solutions
PEHOWE
16-Pearl
(To:ague)

Hello @ague 

 

By definition a Radio button group can only have one selected option. When you provide the Radiogroup item name you are grouping the radio buttons so that the UI can update the other members of the group, when you make a selection.  In regards to the information which is returned to a service there is the state which is generally a Boolean (true/false) and the event of the stateChanged.  

 

Each radio button in a group will have a State but only one is true.

 

You can bind the state of each button to your service as an input and use the Statechanged event as the trigger to the service to process the information. 

 

If you want to allow multiple items to be selected then a CheckBox is the preferred item.

 

Hope this helps

View solution in original post

8 REPLIES 8
PEHOWE
16-Pearl
(To:ague)

Hello @ague 

 

By definition a Radio button group can only have one selected option. When you provide the Radiogroup item name you are grouping the radio buttons so that the UI can update the other members of the group, when you make a selection.  In regards to the information which is returned to a service there is the state which is generally a Boolean (true/false) and the event of the stateChanged.  

 

Each radio button in a group will have a State but only one is true.

 

You can bind the state of each button to your service as an input and use the Statechanged event as the trigger to the service to process the information. 

 

If you want to allow multiple items to be selected then a CheckBox is the preferred item.

 

Hope this helps

ague
12-Amethyst
(To:PEHOWE)

"By definition a Radio button group can only have one selected option.

  • okay, so it can only have one selected option - fine. But can I at least get a list of radio buttons for the user to select from? Say I have a service that returned an array (for example: ['dog', 'cat', 'goldfish', 'horse']). I would like to create a radio button for each of my array items that is returned. For example, the first radio button will read 'dog', the second radio button will read 'cat', etc etc. Can I bind this service to the 'RadioGroup' property? I attempted to test this on my own and I can only ever get the first value of my array (ex: 'dog') to show. Is this what you mean by 'selected' option?

"When you provide the Radiogroup item name you are grouping the radio buttons so that the UI can update the other members of the group, when you make a selection."

  • okay, so does this really mean that the RadioGroup feature is really just for naming a group of radio buttons and nothing more? Like I could dynamically name my group 'Pets' but I couldn't dynamically set the options of radio buttons for the user to choose from? What's the point of that?

 

rjanardan
16-Pearl
(To:ague)

RadioGroup is a means to say, these radio buttons belong to one group(say Pets) and only one option should be allowed to be chosen from these, at a time. 

rjanardan
16-Pearl
(To:ague)

One possible way to achieve your requirement would be to have a thing with properties as let's say pet1,pet2 etc with string values as Cat, Dog etc. In mashup, you could add GetPropertyValues service and from the returned data bind pet1, pet2 etc to corresponding radio buttons. When you want to change the labels you may update the property values. 

ague
12-Amethyst
(To:rjanardan)

"In mashup, you could add GetPropertyValues service and from the returned data bind pet1, pet2 etc to corresponding radio buttons."

  • Okay, but what if the size of data returned is different each time? For example, I want to display a radio button of pets available for purchase from a pet store. One day, there are 3 pets available to purchase, so I need 3 radio buttons. But the next day, there are 5 pets available for purchase so I'll need 5 radio buttons. Is this achievable? 
eliotlandrum
12-Amethyst
(To:ague)

It seems like a drop down list would be better suited for your use there. In typical UX (not specific to ThingWorx), radio button groups are not dynamically created from data sets.

Hello @ague ,

You are trying to get information from a radio button which is not the information it was designed to return. In regard to your questions:

  • Can you set the labels on the radio buttons from a service? YES
  • Can you set the RadioGroup on the radio buttons from a Service? Yes
  • Can you have a dynamic number of Radio buttons? Yes, it is possible to build all the items on a dialog dynamically on the fly. That does not make it a wise design choice.

For each radio button in a group you can test its value and determine if it was selected. Each Radio button returns a selected or not selected value. I believe you are expecting the radio button or group of radio buttons to return the name/value of the one which is selected.

 

That is not how it was designed to work.

 

If you are working with a dynamic entries a drop down list would be a better choice. Multi selection is supported for a drop down item.

 

  

ague
12-Amethyst
(To:PEHOWE)

Thank you for the clarification! 

Top Tags