DMXzone Server Connect Support Product Page

This topic is locked

How do i assign a dynamic value to a checkbox group?

Asked 08 Apr 2020 12:56:49
1
has this question
08 Apr 2020 12:56:49 Bruce Wilkie posted:
Hi there

This is a follow up to another question that's now marked as answered. Unfortunately i had to take a couple of weeks off from it, but back to it now.

I've posted this in the original question, but as it's now marked as answered I don't know if anyone will see my additional post in that question, so just to be on the safe side, I'm starting this new question on the system.

If this is unneccessary, and you can see the update in the original question, then please feel free to delete this question from the system and continue in the original thread instead, with my apologies for the duplication.

Otherwise, here's what I'm wanting to do...

I have a checbox group set up on a test page, populated from a database table. I have a second database table which has entries showing which of the checkboxes should be already ticked on opening the web page.

Below is the code I have set up for this in the test page. Can you tell me if I've got it right as it's not working for me:


<div class="checkbox-group" id="categories" is="dmx-checkbox-group" dmx-bind:value="serverconnectListCategoriesChecked.data.queryListCategoryLinks.values("product_id.values"">
<div dmx-repeat:repeat1="serverconnectListProductCategories.data.queryListCategories">
<label dmx-class:selected="checkbox.checked">
<input name="checkbox" type="checkbox" id="checkbox" dmx-bind:value="product_cat_id">
{{product_cat_name}}</label>
</div>
</div>

I was advised in the original question that I posted that the expression I use for the checkbox group component should be formatted like
yourServerConnect.data.yourQuery.values("yourValueBinding")


But when i do that I can see there's a problem with repeated quotation marks in this part:
dmx-bind:value="serverconnectListCategoriesChecked.data.queryListCategoryLinks.values("product_id")"


So I took out the inner quotation marks to fix that issue, like this:
dmx-bind:value="serverconnectListCategoriesChecked.data.queryListCategoryLinks.values(product_id)"
But it still doesn't seem to work.

And changing the outer quotation marks to single quotes (or doing the same to the inner quotation marks) doesn't fix it either.

If you can let me now if I've got this bit right then it must be an issue elsewhere. I'm displaying the results of serverconnectListCategoriesChecked query on the page, so i know that the server action is working properly

Also, I couldn't find 'values' as an option to select for the query when I clicked on the lightning to set the value of the checkbox group, so that may provide a clue: prntscr.com/rvdx80

I know I'm nearly there, I just don't know how i've got this last bit wrong. Really appreciate your patience and help with this.

Replies

Replied 09 Apr 2020 07:24:42
09 Apr 2020 07:24:42 Teodor Kuduschiev replied:
Please change the inner quotes to ' or escape them like &quot;
Replied 09 Apr 2020 13:52:05
09 Apr 2020 13:52:05 Bruce Wilkie replied:
Thanks Teodor. I've now tried that but it hasn't worked I'm afraid.

Full code for the test page below, including a repeat below the checkbox group that shows the id's of the boxes that should be ticked.

Are you able to see what I'm doing wrong in the page code below?

<body id="test1" is="dmx-app">
<dmx-serverconnect id="serverconnectListProductCategories" url="../dmxConnect/api/adminarea/Projects/ListProductCategories.php" site="undefined"></dmx-serverconnect>
<dmx-serverconnect id="serverconnectListCategoriesChecked" url="../dmxConnect/api/adminarea/Projects/ListProductCategoryLinks.php" site="undefined" dmx-param:filter="query.projectid"></dmx-serverconnect>
<form id="form1" name="form1" method="post">
  <div class="checkbox-group" id="categories" is="dmx-checkbox-group" dmx-bind:value="serverconnectListCategoriesChecked.data.queryListCategoryLinks.values('product_cat_id')">
   
    <div dmx-repeat:repeat1="serverconnectListProductCategories.data.queryListCategories">
     	<label dmx-class:selected="checkbox.checked">
	      <input name="categories" type="checkbox" id="categories" dmx-bind:value="product_cat_id">
	      {{product_cat_name}} - {{product_cat_id}}</label>
    </div>
    
  </div>
</form>
<p>These should be ticked...</p>
<p dmx-repeat:repeat2="serverconnectListCategoriesChecked.data.queryListCategoryLinks">{{product_cat_id}}</p>

</body>

Replied 09 Apr 2020 14:06:37
09 Apr 2020 14:06:37 Teodor Kuduschiev replied:
Hi Bruce,
Everything you need is explained in the Wappler forum. Please check this topic:

community.wappler.io/t/update-form-with-dynamic-checkboxes/15865/4
Replied 09 Apr 2020 14:16:22
09 Apr 2020 14:16:22 Bruce Wilkie replied:
Thanks Teodor.

I've looked at that forum thread now and as far as I can see I've followed the format exactly. But it's not working. Are you able to look at my code above to see if there's a mistake there that i've missed?
Replied 09 Apr 2020 14:24:44
09 Apr 2020 14:24:44 Teodor Kuduschiev replied:
IT would be easier to spot any issues if you provide a link to your page.
Replied 09 Apr 2020 14:33:40
09 Apr 2020 14:33:40 Bruce Wilkie replied:
Replied 09 Apr 2020 14:36:21
09 Apr 2020 14:36:21 Teodor Kuduschiev replied:
The dmx formatter include is missing from the page.

Format some data on the page - like add some binding and apply the simplest formatter so the js can be copied on the page.
Replied 09 Apr 2020 14:44:49
09 Apr 2020 14:44:49 Teodor Kuduschiev replied:
And also please change the expression to:


serverconnectListCategoriesChecked.data.queryListCategoryLinks.values(`product_cat_id`)


so it uses backticks `
Replied 09 Apr 2020 14:46:28
09 Apr 2020 14:46:28 Bruce Wilkie replied:
Thanks Teodor. Have now done that and the formatter link is now included, but for some reason the boxes still aren't being checked
Replied 09 Apr 2020 14:48:15
09 Apr 2020 14:48:15 Teodor Kuduschiev replied:
And also please change the expression to:


serverconnectListCategoriesChecked.data.queryListCategoryLinks.values(`product_cat_id`)


so it uses backticks `
Replied 09 Apr 2020 15:00:53
09 Apr 2020 15:00:53 Bruce Wilkie replied:
OK, done that now. Still not checking the boxes though I'm afraid
Replied 09 Apr 2020 15:14:52
09 Apr 2020 15:14:52 Teodor Kuduschiev replied:
Then i will have to investigate more. Unfortunately i can't see any error in the code.
It might be that DW extensions did not get all of the Wappler functionality for operations like this. I will get back to you when i have more info.
Replied 09 Apr 2020 15:30:47
09 Apr 2020 15:30:47 Bruce Wilkie replied:
Thanks Teodor. Appreciate you looking into this for me. Have a good Easter, you and the rest of the DMX Team
Replied 20 Apr 2020 08:58:52
20 Apr 2020 08:58:52 Bruce Wilkie replied:
Hi Teodor

Just wanted to check if the team have worked out how to fix the problem yet? My project is currently on hold while this is being worked on and I need to update the client.

thanks
Bruce
This reply was removed on 9/26/2023 6:17:54 AM.
See the changelog

Reply to this topic