Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10
Accepted Solution

Radio Button issue: selected property of Option doesn't work

I want an Option out of two options of the radio group to be selected by default at the start of the application.

Following are the ways I've tried.

 

using QML:

 

Page {
content:
Container {
RadioGroup {
Option {
selected: true
text: "Female"
value: Female
 }
Option {
text: "Male"
value: Male
}
}
}
}

 

 

using cpp code:

 

QmlDocument *qml = QmlDocument::create("main.qml");
AbstractPane *root = qml->createRootNode<AbstractPane>();

RadioGroup *group = RadioGroup::create().add(Option::create().text("option 1").selected(true)).add(
Option::create().text("option 2")).add(
Option::create().text("option 3"));

Application::setScene(Page::create().content(group));

 

in Both the ways, I get options with text, but default selection is not done.

Please use plain text.
Developer
soaman
Posts: 848
Registered: ‎03-03-2011
My Device: Z10

Re: Radio Button issue: selected property of Option doesn't work

[ Edited ]

Use quotation marks for for value tag.

 

If it doesn't help, can you try this:

 

Page

{
  content:

    Container

    {

      RadioGroup

      {

        onCreationCompleted:

          {

            female.selected = true;

          }

 

        Option

        {

          id: female
          text: "Female"
          value: "Female"

        }
        Option

        {

          id: male
          text: "Male"
          value: "Male"
        }
      }
    }
}

--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Please use plain text.
Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10

Re: Radio Button issue: selected property of Option doesn't work

ya..! it worked ! thanks soaman !!

Please use plain text.
Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810

Re: Radio Button issue: selected property of Option doesn't work

It means there is no use of selected : true/false  property of Option element .

Also what is the use of selectedIndex property of RadioGroup control. I did not find any use of it in the selection of one of the provided options of a RadioGroup.

 

 

Always Success
Please use plain text.