cschuff
cschuff

Reputation: 5542

Binding sap.m.RadioButton

how do I bind the selected property of sap.m.RadioButtons? I understood that I group them with the groupName property but I'm totally missing sth. like RadioButtonGroup to get the selected key or alike. sap.m.RadioButton does not even provide a key? Could someone give an example?

<RadioButton groupName="MyGroup" text="Option A" selected="true" />
<RadioButton groupName="MyGroup" text="Option B" />

Say my model looks like this:

{ currentOption: "A" }
{ options : [ { "name" : "A" }, { "name" : "B" } ] }

The alternative option would be "B". How to map this?

BR Chris

Upvotes: 0

Views: 856

Answers (1)

Blaesius
Blaesius

Reputation: 144

You are right, you can use the property groupName to group the RadioButtons and with property selected you set the selected RadioButton. The binding can be done as usual, you would bind the text against your name and if you would like to bind the selection as well, then you would have to put this into your data as well. Your data would look like this:

{ options : [ { "name" : "A", "selected" : "true" }, { "name" : "B" }, "selected" : "false" ] }

If you have a look at www.github.com/SAP/openui5/ you can check the master branch, there is already a sap.m.RadioButtonGroup which you can use for testing. It will probably come with the next release.

BR, Janina

Upvotes: 1

Related Questions