Hi all, I have a dropdown I am using to function as a search. I have it set up to show values, and when one is chosen it works beautifully. However I cannot get it to revert back to the original options once an option has been chosen. Please can you offer some advise? Code below:
import wixData from 'wix-data';
$w.onReady(function () {
wixData.query("Reviews")
.limit(100)
.find()
.then(results => {
const uniquecompanyToReview = getUniquecompanyToReview(results.items);
$w("#companyreviewdropdown").value = undefined;
$w("#companyreviewdropdown").options = buildOptions(uniquecompanyToReview);
});
function getUniquecompanyToReview(items) {
const companyToReviewOnly = items.map(item => item.companyToReview);
return [...new Set(companyToReviewOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
});
export function companyreviewdropdown_change(event) {
let SearchValue = $w("#companyreviewdropdown").value;
$w("#reviewdataset").setFilter(wixData.filter().contains('companyToReview', SearchValue)
);
}
Try adding a reset button on the page.
There is a good example from Vorbly here.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-RESET-FORM-WITH-BUTTON
Otherwise, simply search the forum itself for reset button and you will get many old posts back...
https://www.wix.com/corvid/forum/community-discussion/reset-button-search
https://www.wix.com/corvid/forum/community-discussion/how-to-reset-my-my-dropdown-to-show-all-items
https://www.wix.com/corvid/forum/community-discussion/reset-the-dropdown
https://www.wix.com/corvid/forum/community-discussion/resolved-clear-reset-imput-field
https://www.wix.com/corvid/forum/community-discussion/reload-page-and-clear-reset-filters
https://www.wix.com/corvid/forum/community-discussion/reset-filters-and-filter-all