I had posted " Dynamic radio group?" previously, but want I want to do is bind a radio group to a table in MySQL as shown. It looks like this is not possible, as I get an expression error. Is there a way to dynamically bing a radio group to a database table?
Hi @pdixon, you will need to use a script transform in the binding and iterate through the dataset to provide the correct structure that the radios array is expecting. If you want to then save this back to the database you will need to use an onChange script or the appropriate event handler for the component to update the database.
If you need any further information, let me know.
return format json might be enough, maybe if the query is good constructed xd
How would I get the size of the array from the MySQL table? I need to look at the number of rows in the table and pass that into the expression. Is there a way to do that?
I tried this, but it doesn’t work
Great! But it looks dirty
I welcome any cleaning recommendations, but I am pressing on since I have it working
have you tried pressing this
and set it to json format?
I would start by changing binding type from expression to named query, avoiding that weird reference to the DB table name. That only have sense if the table name is dynamic.
Ones you have data from the query you can do the transform if needed.
To get the length of rows, avoid creating another query using
COUNT(*), just use
.rowCount, depending on the return format.
You loop looks ok.
And last, you have two
return in the same indent, that has no sense. I don’t know how that is even working.
I cleaned it up by recognizing that the fields were not being mapped because I was not returning them with the right names for the radio button. Now I have a query that returns the right names for a clean implementation.
Thanks for everyone’s help.