Checkboxes within a collection list

I’m trying to set up a dropdown menu that persists, not like the current multi-select drop downs. I want to use checkboxes to build an array that I can use for filtering. When I build a checkbox inside of a collection list, no variable is created. I’m therefore unable to monitor the value of that checkbox. I’m also unable to bind that checkbox value if I wanted a “select all” or “clear all” feature. I’m only able to bind the initial value, which is useless after the page loads. Looking for suggestions. The two other options I can think of are using the

  1. Multi-select dropdown (not preferred or clean)
  2. Data grid (not preferred because can’t have the checkbox on the right side).

1 Like

I’m pretty sure that with some Javascript you can use the datagrid.
The datagrid comes with an array Datagrid - selected rows, which is still there even if you disable ‘Allow Selection’, however, you can always create your own array if needed.
For the custom checkbox add to the On Click workflow a JavaScript Array push (JavaScript Array push() Method) or some other javascrpt array method which manipulates the array. In this video Loom | Free Screen & Video Recording Software | Loom
You can see that I added a workflow to a button that adds the first element to the datagrid selected array.
What you would need to do is something kind of like
if (datagrid selected array contains current item){
remove from datagrid selected array (current item)
} else {
datagrid selected array add (current item)
}

No need for javascript or other components. You can do everything with nocode in weweb.
You just need to create a variable that stores the selection and add some workflows to update the variable when you change the value of the checkboxes.

A basic example:

the end result is this:
chrome_M0WgcgntbG

4 Likes

Thank you for the guide, let me test this out and see if I can add the array as a conditional filter to the feed.

I must have understood init value incorrectly, it looks like it continually updates on change not just the initial value on page load.

Hello Dori,
Your guide is pretty clear, i just have a strugle finding the elements you’re mentioning, quite few things have changed on weweb.io since couple of weeks.

Can you explain how i can check the value of a checkbox in a collection list, the objective is simply to know if an element is checked or not?

Thanks in advance.

what it is that you can’t find?

To know if a checkbox in a collection list is checked or not you need to add the logic to keep track of this information.

The guide in my previous post is a basic example of how to do that.

Do mind that this is for a collection list or a container that displays a list of items. If you are using a datagrid element it will keep track of the selected rows automatically.

Mariano

Hi Dorilama,

The major issue as that i don’t have init value in checkbox, and no “on change” in the checkbox workflow, but in your example, you have it.

It may be linked to the changes made on weweb lately.

I figured a work around it with this workflow in the checkbox, on click:

There is two checkbox element:

  • One purely visual
  • On which is an input, containing the first one and having all the properties you want.

Can you double check you select the correct one?

1 Like

For some reason the remove action I have binded is not working anymore

chrome-extension://mmeijimgabbpbgpdklnllpncmdofkcpn/app.html#/files/d3ba392c-7ddc-4865-y471-1bc30d367b31

HI,
can you provide more context? Is it link to previous topic?

I have already solved this thanks anyway!

This was very helpful and worked for me in April 2023. Thank you.

4 Likes