top of page
Forum Posts
Rémi Pommereuil
Aug 10, 2020
In Coding with Velo
Hello, I'm creating a page with differents publications. Users can check a multicheckbox to filter a category of publications. I wrote the code for it and it works properly. However, when no category is checked, I would like all publications appear on the page.. but I can't find the right code.. Could someone help me to find the right solution please ? Here is my code : import wixData from 'wix-data';
$w.onReady(function () {
filterView();
$w("#checkboxGroup1").onChange( (event, $w) => {
filterView();
});
});
function filterView(){
var categoriesFilter = $w("#checkboxGroup1").value
console.log('categories',categoriesFilter);
$w("#publications").setFilter(wixData.filter()
.hasSome("categories",categoriesFilter)
)
.then( () => {
let count = $w("#publications").getTotalCount();
if(count === 0){
$w("#repeater1").hide();
}else{
$w("#repeater1").show();
}
} )
.catch( (err) => {
console.log(err);
} );
} For more precisions : my dataset name is : publications publications are in a repeater called "repeater1" the dataset field filtered is : categories and the mutlicheckbox is "checkboxGroup1" Thanks a lot for your help !! 🙂
0
3
60
Rémi Pommereuil
More actions
bottom of page