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.

Documentation

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. Must be set in JavaScript. 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.
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.
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 in JavaScript.
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 (Django tag)

{% radiogroup id="example-radiogroup" default="One"%}

Example (JavaScript)

<script>
    var deps = [
        "splunkjs/ready!",
        "splunkjs/mvc/radiogroupview"
    ];
    require(deps, function(mvc) {
        var RadioGroupView = require("splunkjs/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.getInstance("example-radiogroup").settings.set("choices", choices); 

    });
</script>

Code examples