Guys, I need you. DESPERATELY.
I have a repeater that is connected to a database. Also, I have 3 dropdowns that work perfectly with each other. My code does automatically avoid showing duplicates. However, recently I have added the pagination bar and whenever I click on the next page, the duplicates show up. When I click back, the duplicates disappear and the repeater looks clean again. What I would like to have is whenever I click to the next page, the repeater will show the data without duplicates.
Please help me - I buy ice cream for anybody living in Switzerland who can help me figure this out.
Many thanks
Mario
Well showing your used code along with any screenshots etc would be a good starter, otherwise other forum users will just be guessing at what could be wrong.
Hi Boss,
Here it is my man. Youll get a whiskey
import wixData from ‘wix-data’;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
let SearchValue = $w(“#iTitle”).value;
$w(“#dataset1”).setFilter(wixData.filter().contains(‘firma’ , SearchValue)
.or(wixData.filter().contains(‘plzort’ , SearchValue)
.or(wixData.filter().contains(‘hauptkategorie’ , SearchValue)
)))
.then(()=> {
omitDuplicates();
})
}
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
}, 200);
$w.onReady( function () {
uniqueDropDown1();
uniqueDropDown2();
});
function omitDuplicates() {
let data = $w(“#repeater1”).data;
let newData = ;
data.forEach(e => {
if (!newData.some(o => o.firma === e.firma)){
newData.push(e);
}
})
$w(“#repeater1”).data = newData;
}
$w.onReady( function () {
$w(“#dataset1”).onReady( () => {
omitDuplicates();
})
})
function uniqueDropDown1 (){
wixData.query(“Memberlistev2”)
.ascending(“hauptkategorie”)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdown1”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.hauptkategorie);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
function uniqueDropDown2 (){
wixData.query(“Memberlistev2”)
.contains(“hauptkategorie”, $w(“#dropdown1”).value)
.ascending(“subkategorie”)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdown2”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.subkategorie);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
function uniqueDropDown3 (){
wixData.query(“Memberlistev2”)
.contains(“hauptkategorie”, $w(“#dropdown1”).value)
.contains(“subkategorie”, $w(“#dropdown2”).value)
.ascending(“kanton”)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdown3”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.kanton);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
export function dropdown1_onChange(event) {
uniqueDropDown2();
$w(“#dropdown2”).enable();
$w(“#dataset1”).setFilter( wixData.filter()
.eq(“hauptkategorie”, $w(“#dropdown1”).value) )
.then(()=> {
omitDuplicates();
})
}
export function dropdown2_onChange(event) {
uniqueDropDown3();
$w(“#dropdown3”).enable();
locationBereichFilter2();
}
export function dropdown3_onChange(event) {
uniqueDropDown3();
locationBereichFilter3();
}
function locationBereichFilter2 (){
$w(“#dataset1”).setFilter( wixData.filter()
.eq(“subkategorie”, $w(“#dropdown2”).value)
.contains(“hauptkategorie”, $w(“#dropdown1”).value)
);
}
function locationBereichFilter3 (){
$w(“#dataset1”).setFilter( wixData.filter()
.eq(“kanton”, $w(“#dropdown3”).value)
.contains(“hauptkategorie”, $w(“#dropdown1”).value)
.contains(“subkategorie”, $w(“#dropdown2”).value)
);
}
export function clearFIlters_onClick(event) {
$w(“#dropdown1”).value = 0;
$w(“#dropdown2”).value = 0;
$w(“#dropdown2”).disable();
$w(“#dropdown3”).value = 0;
$w(“#dropdown3”).disable();
$w(“#dataset1”).setFilter(wixData.filter())
.then(() => {//<< You need this “then”
$w(“#iTitle”).value = “”; omitDuplicates();
})
}
export function pagination (event) {
omitDuplicates();
}