Question:
Does my code look correct - it doesn’t seem to be working? Dyanmic Dataset search bar
Product:
Velo
What are you trying to achieve:
I am trying to get my search bar to search using company name however it doesn’t return the company name
What have you already tried:
import wixData from ‘wix-data’;
$w.onReady(function () {
//SEARCH BUTTON TRIGGER⚡
$w("#searchButton").onClick(function () {
search();
});
//ENTER KEY TRIGGER⚡
$w("#searchBar").onKeyPress(function (event) {
if (event.key === "Enter") {
search();
}
});
//SEARCH FUNCTION🚀
function search() {
$w("#dataset1").onReady(function () {
$w("#dataset1").setFilter(wixData.filter().contains('companyName', String($w('#searchBar').value))
.and(wixData.filter().contains("industry", String($w('#dropdown1').value)))
.and(wixData.filter().contains("subIndustry", String($w('#dropdown2').value)))
.and(wixData.filter().contains("companySize", String($w('#dropdown3').value))))
.then(count)
$w("#resetButton").show();
})
}
//COUNT FUNCTION👍
function count() {
let count = $w("#dynamicDataset").getTotalCount();
if (count > 0) {
$w("#countText").text = `${count} items found`;
} else { $w("#countText").text = `No item found`; }
return count;
}
//CLEAR FILTER 🚀
$w("#resetButton").onClick(function () {
$w("#dropdown1").value = undefined;
$w("#searchBar").value = undefined;
$w('#dropdown2').value = undefined;
$w('#dropdown3').value = undefined;
$w("#resetButton").hide();
$w("#dynamicDataset").setFilter(wixData.filter()).then(count);
});
//COUNT BEFORE PAGE LOADS❗
$w("#dynamicDataset").onReady(function () {
count();
});
});
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]