According to the docs, the optionsConfig can be used for this purpose:
> The config of the options components. For selections of type "checkbox" and "radio" optionsConfig will be passed to every single CheckBox or Radio. For "select" and "combobox" optionsConfig will be passed to the underlaying ComboBox.
For checkbox, here's what the docs say about checked:
> true if the checkbox should render initially checked (defaults to false)
So for my dialog, I have configured a selection widget like this:
<test jcr:primaryType="cq:Widget"
options="/apps/.../options.json"
xtype="selection"
type="checkbox">
<optionsConfig jcr:primaryType="nt:unstructured" checked="{Boolean}true"/>
</test>
options.json:
[
{
"text": "Option 1",
"value": "option1"
},
{
"text": "Option 2",
"value": "option2"
}
]
However this is not causing all the checkboxes to be checked initially.
What is the proper, non-hacky way of doing this?
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Use the defaultValue property and insert the values you want to have selected from start. See [1] for an example.
Also, each checkbox is an item of its own and can have the boolean value true (checked) of false (unchecked). This is not radio buttons, right?
/Ove
[1] http://localhost:4502/crx/de/index.jsp#/libs/foundation/components/list/dialog/items/list/items/feed
Views
Replies
Total Likes
Use the defaultValue property and insert the values you want to have selected from start. See [1] for an example.
Also, each checkbox is an item of its own and can have the boolean value true (checked) of false (unchecked). This is not radio buttons, right?
/Ove
[1] http://localhost:4502/crx/de/index.jsp#/libs/foundation/components/list/dialog/items/list/items/feed
Views
Replies
Total Likes
The difference between my case and that CQ 5 example is that I am rendering multiple checkboxes. Should I set the defaultValue to "option1,option2"?
Views
Replies
Total Likes
This works in case of options arbitrarily added while creating the dialog.
It doesn't seem to work for options populated via a JSON or servlet.
I have tried <optionsConfig jcr:primaryType="nt:unstructured" checked="{Boolean}true"/> as mentioned above. To set defaultValue property as an array of values, since the options are dynamically generated, is there a way to dynamically set this property "defaultValue"? Or any other approach to have the checkboxes selected initially?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies