I am doing a 2 drop down filter search interface with deduplication feature with the following code. the item.country field is a reference field from another dataset “CountryCode”
is there anyway to display a specific field in “CountryCode” instead of the id?
$w.onReady(function () {
uniqueDropDown1();
});
function uniqueDropDown1 (){
wixData.query(“Attractions”)
.ascending(“titles”)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#iCountry”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.country);
return […new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
export function iCountry_change(event, $w) {
uniqueDropDown2();
$w(“#iCity”).enable();
}
function uniqueDropDown2 (){
wixData.query(“Attractions”)
.contains(“country”, $w(“#iCountry”).value)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#iCity”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.city);
return […new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
export function iCity_change(event, $w) {
filter(lastFilterTitle, $w(‘#iCity’).value);
}