Need help with Dynamic Checkbox List databinding for update

Node as my server model and MS SQL as the database backend. I need some help. Maybe I have been looking at it too long. I can’t get it to work. Here is what I have.

I have a Checkbox list that is populated from a table. I am inserting a one to many relationship into another table. That part works fine, as I can check as many checkbox items as needed and they are inserting into the database, with each checkbox value going into one record row. The problem is when I put those checkboxes in an edit form and try to dynamically check those based on the data from the one to many table.
This is what my checkbox list look like on the page:


And this is my code:

                                
                                <div class="form-group mb-3" id="LocationGroup" is="dmx-checkbox-group" dmx-bind:value="scUserToLocationForBinding.data.queryUserToLocationListForBinding">
                                    <div class="form-check" dmx-repeat:repeat1="scLocationList.data.queryLocations">
                                        <input class="form-check-input" type="checkbox" value="" id="LocationID" name="locationID" dmx-bind:value="LocationId">
                                        <label class="form-check-label" for="LocationID">{{LocationName}}</label>
                                    </div>
                                </div>


                            </div>

This is in Wappler:

I have followed the How-to here Dynamically check Radio Buttons and Checkboxes
And other post but I just can’t get it to work. Nothing gets checked dynamically in my list.

Let me know if I need to post some more code or examples to help explain my issue.

Thanks,
Chris

You need to save each checkbox value in a table?
Use a repeat form

Hey @turn3636,

I would check for a type mismatch…
Checkbox values are string, so please check the datatype of form-group value (scUserToLocationForBinding.data.queryUserToLocationListForBinding)

What type of data is returning? Numeric or String?

The insert is working fine, I do have that in a repeater and it is inserting multiple records into multiple rows. The issue is on the update, in the interface and to check the ones that are coming over in my datsource that is populating those cheacks.

I am actually saving a guid for the values, and returning a guid for the checks. The format is strings for both.

uuid you mean…

dmx-bind:value="scUserToLocationForBinding.data.queryUserToLocationListForBinding"
You bind the whole query in the form-group or I am wrong?
You should bind there the field/column of that query that contains the value, right?

Yes! I think that is where the issue is. I have tried to bind just the LocationID field, but that does not work either. I don’t have something right for the binding. I am binding it to the checkbox group like the video shows, but I don’t know how to get just the locationID to bind to the checkbox.

Please lick the lightning bolt here and post a screenshot of the scUserToLocationForBinding.data.queryUserToLocationListForBinding fields that appears…

I know I need the locationID in there, but when I select just that field instead of the recordset, it still does not work.

bind the LocationID

*Note:
I see similar names in there…


Please check that the right field of dmx-repeat:repeat1="scLocationList.data.queryLocations" is LocationId and not LocationID
(just in case)

**

Note 2: (edit)

So in your dmx-repeat:repeat1=“scLocationList.data.queryLocations” I suppose that the same uuid values are stored and you bind them to your checkboxes value. Because these values are going to be matched with the form-group value

ok, we are almost there… It is working, sort of. This is the issue I ran into earlier. So I did bind it to the LocationID and make sure all the field names match LocationID - LocationID and it does now bind to the checkbox… But only one. It has to do with the single row from the data binding:


And on the screen.

Try
scUserToLocationForBinding.data.queryUserToLocationListForBinding.split(,)

Thanks for the help, but adding that does not even show the one.

Famousmag, I found the issue. Looks like this post back in '19 had the same issue. You were very close. Thank you so much for helping!

1 Like