CheckboxGroupView

Description
The CheckboxGroup view displays a group of checkboxes, allowing you to populate a set of checkboxes with a search. You can also use this view like a standard HTML checkbox group.
Library path
splunkjs/mvc/checkboxgroupview
Simple XML wrapper
Properties
Name | Default value | Description |
id | | Required. The unique ID for this control. |
choices | [] | A static dictionary of choices for the checkbox group. 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"}
]; |
default | | The value of the choices that are selected by default. Multiple default choices can only be set in JavaScript as an array. |
disabled | false | Indicates whether to disable the view. |
initialValue | | The initial value of the input. If defaultis specified, it overrides this value. |
labelField | "" | The text or search field to use as the labels for the checkboxes in this group. If labelField is not defined, the valueField is used as the label. |
managerid | null | The ID of the search manager to bind this control to. |
settings | | The properties of the view. See the methods below to get and set values. |
value | | A comma-separated list of values that are currently selected. |
valueField | "" | The value, or search field to provide the value, for the checkboxes in this group. |
Methods
Name | Description |
getDisplayedChoices | Retrieves a dictionary of the selected choices and their values in the following format:
[
{value: 'val1', label: 'Value 1'},
{value: 'val2', label: 'Value 2'},
...
] |
render | Draws the control 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( property, value ) | Sets the value of property to the specified value for the current component. |
val | Returns an array of values for the checked items if passed no parameters. Sets the checked items if passed an array of values. |
Events
Name | Description |
change | Fired when the value of the view changes. |
Example
require([
"splunkjs/mvc",
"splunkjs/mvc/checkboxgroupview",
"splunkjs/mvc/simplexml/ready!"
], function(mvc, CheckboxGroupView) {
// Instantiate components
new CheckboxGroupView({
id: "example-checkboxgroup",
default: "One, Three",
el: $("#mycheckboxgroupview")
}).render();
// Define choices
var choices = [
{label: "One", value: "One"},
{label:" Two", value: "Two"},
{label:" Three", value: "Three"}];
// Assign choices to the checkbox group
splunkjs.mvc.Components.get("example-checkboxgroup").settings.set("choices", choices);
});