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:
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
The repeater on the publisher’s side:
Also, is there a way to sort the repeater data? (alphabetical order, date added…).
Thanks for your help