Hi All,
is there a way to clear a RadioButtonGroup's selection? I want to have as result a group with no option selected.
Lets say I have a RadioButtonGroup with the first option selected. I want all selections to be cleared when I press a button.
Regards,
Szilamér
Yes, I agree with sai. Try this working example, It may be useful for you. 😊
Will this help? http://jsbin.com/nivehemaya/edit?html,js,output
@sai - Instead of adding len+1. we can try this rb.setSelectedIndex(null);
Regards,
Karthik A
Hi Szilamer,
Try like this -
var oRadioGroup = sap.ui.getCore().byId("yourRadioGrp"); //Get Hold of Radio Button Group oRadioGroup.setSelectedIndex(-1);
But the above is available on/after 1.30 version: No default in RadioButtonGroup · Issue #588 · SAP/openui5 · GitHub
If you are on lower version, a work around would be setting the value +1 to your radio buttons length. Something like -
var oRadioGroup = sap.ui.getCore().byId("yourRadioGrp"); //Get Hold of Radio Button Group var oRadioButtons = oRadioGroup.getAggregation("buttons"); //For Mobile (sap.m) var oRadioButtons = oRadioGroup.getAggregation("items"); //For Desktop (sap.ui.commons) var oLength = oRadioButtons.length; oRadioGroup.setSelectedIndex(oLength+1);
Regards,
Sai Vellanki.
Add a comment