# Repeater and checkbox

**URL:** <https://forum.wixstudio.com/t/repeater-and-checkbox/3624>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [March 23, 2022, 1:38pm UTC](https://forum.wixstudio.com/t/repeater-and-checkbox/3624 "2022-03-23T13:38:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![morganebregaint](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/morganebregaint/32/8672_2.png) [@morganebregaint](https://forum.wixstudio.com/u/morganebregaint)\
**Post date:** [March 23, 2022, 1:38pm UTC](https://forum.wixstudio.com/t/repeater-and-checkbox/3624/1 "2022-03-23T13:38:07Z")

</div>

Hello,  
I am building an image gallery using the repeater and checkboxgroups. However, I have several problems:

- When no box is checked, there is no result for the query. I would like that when no box is checked, all the data of my database is displayed.

- The different checkboxes are additional except I would like them to be optional. For example, the client can filter with checkbowx 1 OR 2 OR 3…

Here is my code:

```javascript
import wixData from 'wix-data';

$w.onReady(function () {
    filterView();
    $w("#checkboxGroup1").onChange( (event, $w) => {
      filterView();
    });
    $w("#checkboxGroup2").onChange( (event, $w) => {
      filterView();
    });
    $w("#checkboxGroup3").onChange( (event, $w) => {
      filterView();
    });
});

function filterView(){
    var categorieFilter = $w("#checkboxGroup1").value
    var solFilter = $w("#checkboxGroup2").value
    var vetementFilter = $w("#checkboxGroup3").value

    console.log('categorie', categorieFilter);
    console.log('themeSolMur', solFilter);
    console.log('typeDeVetement', vetementFilter);
    
    $w("#dataset1").setFilter( wixData.filter()
    .hasSome("categorie", categorieFilter)
    .hasSome("themeSolMur", solFilter)
    .hasSome("typeDeVetement", vetementFilter)
    )
    ;
}

```

The page : [https://animal-crossing-nh.wix.com/astuces/copy-of-motifs](https://animal-crossing-nh.wix.com/astuces/copy-of-motifs)

The repeater on the publisher’s side:

 ![](https://us1.discourse-cdn.com/wix/original/3X/9/1/91b537c7ec48ceac99f1b2d1056edab7d62bab21.jpeg)

Also, is there a way to sort the repeater data? (alphabetical order, date added…).  
Thanks for your help 😊

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [March 23, 2022, 2:36pm UTC](https://forum.wixstudio.com/t/repeater-and-checkbox/3624/2 "2022-03-23T14:36:31Z")

</div>

Use or() Like:

```javascript
function filterView(){
const values = {
categorie: $w("#checkboxGroup1").value,
themeSolMur: $w("#checkboxGroup2").value,
typeDeVetement: $w("#checkboxGroup3").value
};
let filter = wixData.filter();
let i = 0;
Object.keys(values).forEach(k => {
if(values[k]){
filter = i === 0 ? filter.hasSome(k, values[k]) : filter.or(wixData.filter().hasSome(k, values[k]));
i++;
}
})
$w("#dataset1").setFilter(filter);
}

```

Edit: changed “key” to “k”. pay attention.

---

<div class="post-metadata">

**Author:** ![amandam](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/amandam/32/79539_2.png) [@amandam](https://forum.wixstudio.com/u/amandam)\
**Post date:** [March 23, 2022, 2:39pm UTC](https://forum.wixstudio.com/t/repeater-and-checkbox/3624/3 "2022-03-23T14:39:48Z")

</div>

Oh I like this method for getting “or” into the filter. Thanks for the addition!

---

<div class="post-metadata">

**Author:** ![morganebregaint](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/morganebregaint/32/8672_2.png) [@morganebregaint](https://forum.wixstudio.com/u/morganebregaint)\
**Post date:** [March 23, 2022, 5:50pm UTC](https://forum.wixstudio.com/t/repeater-and-checkbox/3624/4 "2022-03-23T17:50:36Z")

</div>

Hi ! Thank you !  
The code is functionning ! If i want to test with additionnal filter, (use “and” rather than “or” as Amanda advised), what should I modify?  
I tried replacing “or” with “and” but it didn’t work.

---

<div class="post-metadata">

**Author:** ![amandam](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/amandam/32/79539_2.png) [@amandam](https://forum.wixstudio.com/u/amandam)\
**Post date:** [March 23, 2022, 8:17pm UTC](https://forum.wixstudio.com/t/repeater-and-checkbox/3624/5 "2022-03-23T20:17:30Z")

</div>

Hello! I just checked your url and I spoke in error. The way you are doing this is returning as expected. Apologies!
