I have a keyword search that is searching over three fields in a table. The search function is working as expected and displays the results in the table, however it is cancelling out the filters I have set on the dataset (settings). When I delete the text from the search box, the table is then showing all results.
How can I have a search field and still maintain the dataset filters? Do I need to include these filters in my code?
The filters:
The code:
import wixData from 'wix-data';
$w.onReady(function (){
});
let debounceTimer;
export function keywordSearch_keyPress(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#keywordSearch').value);
}, 200);
}
function filter(title, jobContact, postCode) {
$w('#dataset1').setFilter(wixData.filter()
.contains('title', $w('#keywordSearch').value)
.or(wixData.filter()
.contains('jobContact', $w('#keywordSearch').value))
.or(wixData.filter()
.contains('postCode', $w('#keywordSearch').value))
)
}
I’m new to coding, so any help would be greatly appreciated!
Thanks