I’m trying to bind the enabling and disabling of a control to the value of a Radio Group e.g. when I click ‘No’ it sets the Radio Group value to 0 and the control is disabled; conversely when I click ‘Yes’ the Radio Group value is set to 1 and the control is enabled.
This seems really basic but it’s not working. Any thoughts on whether this is possible (surely it is!) and what I might be missing?
Did you click the bi-directional checkbox?
I’m trying to animate a control based on the value of the Radio Group, so there is no bi-directional checkbox to check.
I think the issue here is to do with type casting. When I read a TINYINT(1) field from MariaDB it is actually returning a boolean, so I have to manually set the Radio Group value to an integer. I also have to cast this field to an integer before doing a comparison.
What you’re describing isn’t very clear to me. Is there any chance you could provide a screenshot of the binding you have configured to the RadioGroup’s value property?
Perhaps I’m misunderstanding the use-case… Is your Radio Group supposed to change appearance/displayed value based on some other value, or is a value supposed to change based on the value of the Radio Group?
The workflow is a simple CRUD:
- The data is saved in a MariaDB TINYINT(1) field (i.e. a value off 0 or 1)
- When the data is read the record on the screen shows the value of the field using a disabled Radio Group
- When the user edits the record they can use a Radio Group to set the field to true or false. When the field is false the following data entry control is disabled and its label is greyed out. When the field is true the following data entry control is enabled and its label is displayed in a strong colour.
- When the user saves the record the field is updated in the database with the current value (again 0 or 1).
I found that Ignition was getting confused as to whether the false (0) and true (1) values for the Radio Group were integers or strings. Even when I changed these to False and True (which display a checkbox next to them in the Designer), when I read the value in a script it thinks it is a string: ‘false’ or ‘true’. This is why I think it is a type casting issue.
The main issue here seems to be that no matter what values you enter for a Radio Group’s values (e.g. 0 or 1, true or false) it treats the values as strings, despite showing them as numbers or Booleans in the Designer. This means you have to be careful to cast the value before using it in a comparison and before doing something else like saving it to a database.
Ah, I see. You’re actually encountering a known issue which was resolved as part of the 8.1.4 release.