Skip to Content

Clear RadioButtonGroup selection

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 04, 2015 at 06:23 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2015 at 02:53 PM

    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
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.