You can certainly do the filtering, here’s an example of a three level filter where the Cemetery is selected (CemeteryDD) first, then a section (SectionDD) based on which cemetery was selected, then a row (RowDD) within the section. The Section and Row dropdowns are disabled until a cemetery has been selected and row is disabled until a section is selected.
The change_event sections are triggered when a value is selected from the relevant dropdown.
import wixData from ‘wix-data’;
$w.onReady(function () {
$w(“#CemeteryDD”).enable();
$w(“#SectionDD”).disable();
$w(“#RowDD”).disable();
$w(“#dataset1”).onReady(() => {
wixData.query("Cemeteries")
.limit(200)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w("#CemeteryDD").options = cemeteryOptions(uniqueTitles);
$w("#CemeteryDD").enable();
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.title);
return [...new Set(titlesOnly)];
}
function cemeteryOptions(uniqueList) {
return uniqueList.map(curr => {
return {
label: curr,
value: curr
};
});
}
});
});
export function CemeteryDD_change(event, $w) {
$w(“#SectionDD”).disable();
$w(“#RowDD”).disable();
wixData.query(“Cemeteries”)
.limit(1000)
.eq(“title”, $w(“#CemeteryDD”).value)
.find()
.then(results => {
const uniqueBlocks = getUniqueBlocks(results.items);
$w(“#SectionDD”).options = blockOptions(uniqueBlocks);
$w(“#SectionDD”).enable();
});
function getUniqueBlocks(items) {
const blocksOnly = items.map(item => item.block);
return [...new Set(blocksOnly)];
}
function blockOptions(uniqueList) {
return uniqueList.map(curr => {
return {
label: curr,
value: curr
};
});
}
}
export function SectionDD_change(event, $w) {
wixData.query(“Cemeteries”)
.limit(200)
.eq(“title”, $w(“#CemeteryDD”).value)
.eq(“block”, $w(“#SectionDD”).value)
.find()
.then(results => {
const uniqueRows = getUniqueRows(results.items);
$w(“#RowDD”).options = rowOptions(uniqueRows);
$w(“#RowDD”).enable()
});
function getUniqueRows(items) {
const rowsOnly = items.map(item => item.row);
return [...new Set(rowsOnly)];
}
function rowOptions(uniqueList) {
return uniqueList.map(curr => {
return {
label: curr,
value: curr
};
});
}
}
export function RowDD_change(event, $w) {
$w(“#dataset1”).setFilter(wixData.filter()
.eq(“cemetery”, $w(“#CemeteryDD”).value)
.eq(“block”, $w(“#SectionDD”).value)
.eq(“row”, $w(“#RowDD”).value)
);
}