I now need to clear a checkbox that exists in a form, not a repeat.
I have a ‘clear’ button which I’d like to clear all checks. I’ve tried to use a dynamic event that sets the value of the checkbox to 0 and even ‘’ - but I’m getting no luck.
If a user clears the entire form, then i’d like to be able to clear all checkboxes within it.
If the user just wants to clear one section of the form, let’s call it ‘company_size’ that has 5 checkboxes within that form group, I have a button they can click to just clear the checkboxes for that form group of 5 checkboxes.
You can use javascript to check/uncheck checkboxes but this will not fire the change event of the checkbox, which is a problem in most cases - especially when a checkbox is used to filter data.
Maybe @patrick can suggest a good solution here, as we don’t have a “check” dynamic event for the checkbox controls.
Ok, no problem. Not firing the event change would be ok for some of the form groups, but not all of them - so would ideally need an alternative solution or I’ll need to move away from check boxes for this, I guess if @patrick doesn’t have an suggestion.
Do you use the checkbox-group? You can then use the setValue action of it to set the group. For checking/unchecking a single checkbox use the select action on the checkbox.
I’m not using a checkbox-group - I found I couldn’t easily stack checkboxes in a column with the checkbox-group so opted to create individual checkbox inputs one on top of each other.
Hey @patrick - I ended up converting all checks to a group, and just customizing the code within them a bit - and then used this approach, it works great. Thanks!
Hmm, maybe with some modification, it might give some further idea. Thank you.
If I could remove i single entry from a checkbox group value array it would be the simplest way, which is why I tried that first, but I may need to take a longer procedure to achieve it. Although I am indeed still trying to see if the remove may work.
So looks like there is no way I could find to remove a single item from a checkbox groups value, instead I had to
Add the checkbox group values into an empty array <dmx-array id="arrWhere" dmx-bind:items="checkboxGroup.value"></dmx-array>
Them remove from the array itself. But it did work with minimal hassle, however i just imagined i could manually remove an item directly from the checkbox group array itself.
Now on clicking this button the check all does uncheck, but the checkbox in the table does not uncheck (I have tried multiple mentioned sollutions here):