I have a checkbox, and I want the default value to be *, that is All. e.g. device = (device="*")
But once an individual choice is selected I want All to be unselected. e.g. device = (device="Choice1")
How do I do this?
Default All is selected, and then I choose choice1, I get this: device = (device="*" OR device="Choice1")
I do not want this, I want just device="Choice1", where device="*" would be unselected.
This is my code:
<input type="checkbox" token="device" searchWhenChanged="true">
<!-- checkbox dropdown -->
<label>Select a device(for per device, need to unselect all):</label>
<!-- <choice value="*">All</choice> -->
<!-- The final value will be surrounded by prefix and suffix -->
<!-- Each value will be surrounded by the valuePrefix and valueSuffix -->
<!-- All the values and their valuePrefix and valueSuffix will be concatenated together with the delimiter between them -->
<delimiter> OR </delimiter>
<h3> device = $device$</h3>
For the checkbox input, the "form.token" token contains a string with a comma separated string with all the selected values ordered (in my case "*,1,2,3" when all options are selected). With the change > condition options we can check wether or not all is still selected when you select a box another than "all" and just set the "form.token" token to whatever was selected.
by default I have "all" selected.
if I select opt1 (which has a value of 1) my form.chkbox becomes "*,1". the condition case kicks in and sets the form.chkbox to 1 (unselecting the "all" as result). The same logic applies to the other options.
if having opt1 selected e select opt2 my form.chkbox becomes "1,2" so no condition is triggered.
The only caveat here is if you only box selected you can't select "all" before selecting other box first. You'll need to have more than on box selected before the "all" option becomes selectable again. There might be a wait to work around this using condition match instead of condition value but I haven't figured it out yet.