Hi guys,
I have some trouble with my dropdown filter. I want to filter the problem by date and level from my database: after choosing date, the user then choose level and the problem will be displayed. But my code doesn’t work with date picker, the level dropdown is disabled after choose date.
This’s my problem page,
and the problem collection:
Can you tell me how to fix this? Thanks in advance!
Here’s my code: (I’ve just modified my page, so the code may be wrong)
import wixData from ‘wix-data’;
$w.onReady( function () {});
export function datepicker_change(event, $w)
{
$w(“#level”).enable();
levelFilter();
}
function levelFilter()
{
$w(“#pro”).setFilter( wixData.filter().eq(“_updatedDate”, $w(“#datePicker”).value));
}
export function level_change(event, $w)
{
proFilter();
}
function proFilter(){
wixData.query("pro")
.contains("level", $w("#level").value)
.limit(1000)
.find()
.then(results => {
const res = show(results.items);
$w("#problem").text = buildOptions(res);
});
function show(items) {
const titlesOnly = items.map(item => item.fieldkey);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
And my page: https://toan1k97lhp.wixsite.com/toan1k97/problems