RadioGroupView

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
splunkjs/mvc/radiogroupview
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. |
default | | The value of the default radio button. |
disabled | false | Indicates whether to disable the view. |
labelField | "" | The UI label of the radio button. |
managerid | null | The 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. |
value | | The 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 |
render | Draws the view to the screen. Called only when you create the view manually in JavaScript. |
val | Returns the view's value if passed no parameters. Sets the view's value if passed a single parameter. |
Events
Name | Description |
change | Fired 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