Hello guys
I built this code and it’s search and filter with input menu and dropdown menu
It also saves the filter after the customer moves to another page and comes back again, and the search process remains the same, has not changed and was working fine.
Now you are currently showing this error message
An error occurred in a currentIndexChanged callback data set error: The dynamic filter could not be resolved
Can anyone explain where the error is
Please
const PREV_title = 'PREV_TITLE';
const PREV_add = 'PREV_ADD';
const PREV_city = 'PREV_CITY';
let lastFilterTitle;
let lastFilterAdd;
let lastFilterCity;
$w.onReady(() => {
loadmazad();
loadcity();
});
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined; //what is this line for?
}
debounceTimer = setTimeout(() => {
filter($w('#iTitle').value, lastFilterAdd, lastFilterCity);
}, 500);
}
export function dropdown3_change(event, $w) {
$w('#dropdown4').expand();
filter(lastFilterTitle,$w('#dropdown3').value, lastFilterCity);
}
export function dropdown4_change(event,$w) {
filter(lastFilterTitle,lastFilterAdd, $w('#dropdown4').value);
}
function filter(title, add, city) {
if (lastFilterTitle !== title || lastFilterAdd !== add || lastFilterCity !== city) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('bname', title);
if (add)
newFilter = newFilter.contains('add', add);
if (city)
newFilter = newFilter.contains('city', city);
$w('#dynamicDataset').setFilter(newFilter);
lastFilterTitle = title;
lastFilterAdd = add;
lastFilterCity = city
}
//save for next session (and if it's empty, remove any old leftovers)
if (title)
local.setItem(PREV_title, title);
else
local.removeItem(PREV_title);
if (add)
local.setItem(PREV_add, add);
else
local.removeItem(PREV_add);
if (city)
local.setItem(PREV_city, city);
else
local.removeItem(PREV_city);
}
function loadmazad() {
wixData.query('mazad')
.find()
.then(res => {
let options = [{
"value": '',
"label": 'All'
}];
options.push(...res.items.map(add => {
return {
"value":add .add,
"label": add.add,
};
}));
//$w('#dropdown3').options = options;
loadPrevSearch();
});
}
function loadcity() {
wixData.query('mazad')
.find()
.then(res => {
let options = [{
"value": '',
"label": 'ALL'
}];
options.push(...res.items.map(city => {
return {
"value":city .city,
"label": city.city,
};
}));
//$w('#dropdown3').options = options;
loadPrevSearch();
});
}
function loadPrevSearch() {
let prevTitle = local.getItem(PREV_title);
let prevadd = local.getItem(PREV_add);
let prevcity = local.getItem(PREV_city);
if (prevTitle) {
$w('#iTitle').value = prevTitle;
}
debugger;
if (prevadd) {
$w('#dropdown3').value = prevadd;
}
if (prevcity) {
$w('#dropdown4').value = prevcity;
}
if (prevTitle || prevadd || prevcity) {
filter(prevTitle, prevadd, prevcity);
}
}
Hey, You run the function loadPrevSearch before the dataSet ready. try to add $w(“#myDataset”).onReady( () => { …
before filtering the data
hi Binyamin Meron
Thanks for responding to me
Did you mean before
$w("#myDataset").onReady( () => {
function filter(title, add, city) {
if (lastFilterTitle !== title || lastFilterAdd !== add || lastFilterCity !== city) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('bname', title);
if (add)
newFilter = newFilter.contains('add', add);
if (city)
newFilter = newFilter.contains('city', city);
$w('#dynamicDataset').setFilter(newFilter);
lastFilterTitle = title;
lastFilterAdd = add;
lastFilterCity = city
}
//save for next session (and if it's empty, remove any old leftovers)
if (title)
local.setItem(PREV_title, title);
else
local.removeItem(PREV_title);
if (add)
local.setItem(PREV_add, add);
else
local.removeItem(PREV_add);
if (city)
local.setItem(PREV_city, city);
else
local.removeItem(PREV_city);
});
}
@alkanani98 inside the $w . onReady (() => {
$w.onReady(() => {
$w("#dynamicDataset").onReady( () => {
loadmazad();
loadcity();
})
});
Let me know if it solved the issue 
B.
@binyaminm
That didn’t work I still got the same error
const PREV_title = 'PREV_TITLE';
const PREV_add = 'PREV_ADD';
const PREV_city = 'PREV_CITY';
let lastFilterTitle;
let lastFilterAdd;
let lastFilterCity;
$w.onReady(() => {
$w("#dynamicDataset").onReady( () => {
loadmazad();
loadcity();
})
});
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined; //what is this line for?
}
debounceTimer = setTimeout(() => {
filter($w('#iTitle').value, lastFilterAdd, lastFilterCity);
}, 500);
}
export function dropdown3_change(event, $w) {
$w('#dropdown4').expand();
filter(lastFilterTitle,$w('#dropdown3').value, lastFilterCity);
}
export function dropdown4_change(event,$w) {
filter(lastFilterTitle,lastFilterAdd, $w('#dropdown4').value);
}
function filter(title, add, city) {
if (lastFilterTitle !== title || lastFilterAdd !== add || lastFilterCity !== city) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('bname', title);
if (add)
newFilter = newFilter.contains('add', add);
if (city)
newFilter = newFilter.contains('city', city);
$w("#dynamicDataset").onReady( () => {
$w('#dynamicDataset').setFilter(newFilter);
})
lastFilterTitle = title;
lastFilterAdd = add;
lastFilterCity = city
}
//save for next session (and if it's empty, remove any old leftovers)
if (title)
local.setItem(PREV_title, title);
else
local.removeItem(PREV_title);
if (add)
local.setItem(PREV_add, add);
else
local.removeItem(PREV_add);
if (city)
local.setItem(PREV_city, city);
else
local.removeItem(PREV_city);
}
function loadmazad() {
wixData.query('mazad')
.find()
.then(res => {
let options = [{
"value": '',
"label": 'All'
}];
options.push(...res.items.map(add => {
return {
"value":add .add,
"label": add.add,
};
}));
//$w('#dropdown3').options = options;
loadPrevSearch();
});
}
function loadcity() {
wixData.query('mazad')
.find()
.then(res => {
let options = [{
"value": '',
"label": 'ALL'
}];
options.push(...res.items.map(city => {
return {
"value":city .city,
"label": city.city,
};
}));
loadPrevSearch();
});
}
function loadPrevSearch() {
let prevTitle = local.getItem(PREV_title);
let prevadd = local.getItem(PREV_add);
let prevcity = local.getItem(PREV_city);
if (prevTitle) {
$w('#iTitle').value = prevTitle;
}
debugger;
if (prevadd) {
$w('#dropdown3').value = prevadd;
}
if (prevcity) {
$w('#dropdown4').value = prevcity;
}
if (prevTitle || prevadd || prevcity) {
filter(prevTitle, prevadd, prevcity);
}
}
@alkanani98 can you share the site URL, and the page?
Is in this code the member must enter all the fields?
(input iTitle, Dropdown 3 and Dropdown 4)
I have entered all the filter fields and they are working fine
Is there a way to do research on any of them? Without having to complete the three options
Take a look here…
https://www.media-junkie.com/pflegeservice
Can you find some similarity to your project?
Try to use the —> Manual-Search

A new options-window will open…

Choose the field where you want to search for items…and so on…
Type in some SEARCH-WORDS (you can use also multiple searchwords, separated by a “space”).
Of course —> first choose your prefered “example-DATABASE” —> PRESET.
Wanna do some more changements on the example-DATABASES?
Then go to … SETUP…

And play around… 
@binyaminm
Thank you very much Indeed, the code is working correctly
After several attempts to update the screen, it appears that the code was preserving the last filter operation😮
Is there a way to specify a specific time to save the filter, such as only two minutes? The actual problem is that the browser on the mobile keeps the last filter for a very long time
Of course.
Just reset your filter after some specific time.
let myDelayTime = 50000
setTimeout(()=>{ RESET() },myDelayTime)
write your RESET-Function…
Sorry . Can you write the complete code? I am not a professional, I am still beginner in programming
Just wait a little bit, i think Ahmad can help you better 
I asked myself, isn’t it exhausting, to code everytime filtering-engines for new sites? Can’t it be just one FILTER-TOOL which can handle every database in my project? Without all the annoying DATASETs, which have to be setted-up and connected and are not flexible enough?
Why not code a way, without using them ?
The answer you also can see in my given example 
I also started with DATASETs and used them for a long time, because the filtering-process seemed to be very simple when using a dataset.
Yes it is also more simple, but you loose a lot of flexibility (on my opinion).
Wait for Ahmad, he is still typing!
The code you see in the example and the related POST, is the very beginning of the example-tool. Yes, as you can see, i also began by using DATASET.
Then i switched to queries.
You will see in few minutes, just wait some time😉