I am hoping one of the brilliant members of this community can help me with this. I am creating a user interface to enter data into a database. There are two modules, one for adding a new entry, and one for editing an existing entry. I am using a checkbox group (populated by a table) when adding a new entry which allows the user to quickly add multiple items to the database...this is working quite well.
For the editing section, I would like to keep using the checkbox groups. When the user searches the entry, I want all the current associated items for that entry to appear checked so they can either uncheck those or check additional options, but I can't figure out the code to do that.
As a simplified example. Let's say that my main database table is a list of dogs. Each dog would get an ID number. My checkbox Group would be fed by a table for FUR with the options: long, short, black, brown, white, etc. When they enter "Rover", they select short and black, so two entries are made into a DOG_X_FUR table one for "Rover, Short" and one for "Rover, Black". Now when they go to the edit module and look up rover, I want the checkbox group to appear with all of the options, but I want "Black" and "Short" to already be checked.
Sorry, I thought this would be a bit easier with a generic example, but I have built it all out so I am happy to share anything that may help. Here are some screenshots. You will see part of the application with the checkbox group with is just pulling all the descriptions from the reference table in the second screenshot. When someone searches for a door, the app finds the door ID, so if someone looked up door ID 11, you will see that Types associated with that door in the table shown in the third screenshot. I would like those three checkboxes in the checkbox group to be checked. Please let me know if any other details would be useful. I can write SQL to pull all this information, but the Java to get the app to display how I want is not my forte.
The problem is that the checkboxes need to have the value be the ID and the description can be the description...currently you have the value field populated with description... it should be item.id if your data provides the id - if it doesn't - it needs to...
I can certainly make that change, but I'm not sure I understand how that solves the problem...doesn't that just change the value from a string to an integer and change what my SQL code is pulling? I still don't know how to default the checkboxes in the group to a checked status...
For Example, right now if I was just using SQL, I would write something like:
SELECT description
FROM R_BASIC_TYPES
WHERE id IN (SELECT type_id FROM C_DOOR_TO_BASIC_TYPES WHERE door_id = 11)
I can change the value of the checkboxes to id which would certainly be an improvement for workload and processing speed by saving a step and changing that code to:
SELECT type_id
FROM C_DOOR_TO_BASIC_TYPES
WHERE door_id = 11
But I still get the same output, and I don't know how to set those values to default to checked? Is there Java I need to use...maybe in the default value field?
Hi Scott, I think I am close here, and maybe you can help me get across the finish line?
I made some adjustments so it is pulling the ID. To see if I was using the correct field, I added some values to the "Default value" and as you can see, that is checking some of the boxes, though this is static.
In order to try and make it dynamic, I created a query which outputs the same three numbers I used in the test, and then used:
({{ formatDataAsArray(query71.data)}})
in the default value, but as you can see, it doesn't seem to pull the numbers in.