I have a List Collection (CollectionView) with the action type set to Checkbox.
I created a Checkbox press event handler for it that displays an alert if a certain field of the items has a certain value.
In the Alert, I have an OK trigger that triggers a query.
The issue I have is with the Cancel option of the alert. If user clicks Cancel, the query doesn't run, but the checkbox remains checked, which is misleading.
So my questions are:
- How do I prevent the checkbox from being checked if a condition is not met?
- Or, how can I go about clearing the checkbox if user clicks Cancel in the alert?
I see, thanks I'll give it a go. I hadn't considered the Visible screen handler approach.
For the clicking of the checkbox, I wouldn't want it to be disabled. Rather, it would be clickable, but whether the "checking" actually works would be conditional.
So the steps would be:
- Click checkbox
- Check if condition met
- Toggle checkbox accordingly (if condition met and checkbox is currently checked, then uncheck, etc.)
Basically, it would effectively be an "editable" prop.
This is different from a disabled prop, because a disabled prop wouldn't allow for the clicking to work in the first place, and thus no alert would get conditionally displayed.
Yeah, exactly. Think of it like
- click the checkbox & fire checkbox press handler
- do some work, possibly validate with an asynchronous service etc
- possibly revert the check action
What I meant above is that the logic should prevent the checkbox from being clicked/toggled, so you wouldn't have to revert it afterwards.
Having checkboxes that are toggled then reverted is like having queries that first run and then get reverted by some condition.
Yeah, unfortunately not currently possible with the List Collection!
I understand. For right now, I got around it by simply retriggering the query on Cancel, which reinitializes the default value of (all) checkboxes.
I will try the temp state suggestion shortly.