RadioGroupView

The RadioGroup view

Description

The RadioGroup view displays a group of a radio buttons. This view makes it easier to populate a radio button group from a search, but it can also be used like a standard HTML radio button group.

Library path

Simple XML wrapper

Properties

Name

Default value

Description

id Required. The unique ID for this control.
choices[]A static dictionary of options for the radio buttons. If bound to a managerid, the static choices specified here are prepended to the dynamic choices from the search.
For example:
var mychoices = [
    {label:"text1", value: "value1"},
    {label:"text2", value: "value2"},
    {label:"text3", value: "value3"}
];
defaultThe value of the default radio button.
disabledfalseIndicates whether to disable the view.
initialValueThe initial value of the input. If defaultis specified, it overrides this value.
labelField""The UI label of the radio button.
manageridnullThe ID of the search manager to bind this view to.
selectFirstChoice"false"Indicates whether to use the first available choice when the user has not made a selection. If the default property has been set, that value is used instead.
settingsThe properties of the view. See the methods below to get and set values.
valueThe value of the current selection.
valueField""The value, or search field to provide the value, for the radio buttons in this group.

Methods

Name

Description

renderDraws the view to the screen. Called only when you create the view manually.
settings.get( property )Returns the value of property for the current component.
settings.set( propertyvalue )Sets the value of property to the specified value for the current component.
valReturns the view's value if passed no parameters. Sets the view's value if passed a single parameter.

Events

Name

Description

changeFired when the value of the view changes.

Example

require([
    "splunkjs/mvc",
    "splunkjs/mvc/radiogroupview",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc, RadioGroupView) {

    // Instantiate components
    new RadioGroupView({
        id: "example-radiogroup",
        default: "One",
        el: $("#myradiogroupview")
    }).render();

    // Define choices
    var choices = [
        {label: " One", value: "One"},
        {label:" Two", value: "Two"},
        {label:" Three", value: "Three"}];
     
    // Assign choices to the radio button group
    splunkjs.mvc.Components.get("example-radiogroup").settings.set("choices", choices); 

});