I’m having some trouble with my table, after I search an item on my table the sort option that was on the data set is broken instead of showing me = OLD —> NEW
Instead it show = NEW —> OLD
How can I change it back when ever someone searches using the the search box the sort
OLD → NEW, show the item in that order? I’ve read the setSort , but I still don’t understand how it works.
Hey
How do you perform the search in the first place? Do you use setFilter or do you make a new data collection query? Make sure you add .ascending(“fieldkey”) to your query otherwise you will loose it. or what ever sort you have of course.
I keep getting an error with my code, maybe I place the sort code wrong?
$w.onReady(function () {
});
export function searchButton_click() {
wixData.query('Client_Info')
.contains('title', $w('#searchInput').value)
.or(wixData.query('Client_Info').contains('date', $w('#searchInput').value))
.or(wixData.query('Client_Info').contains('keyDates', $w('#searchInput').value))
.or(wixData.query('Client_Info').contains('fact', $w('#searchInput').value))
.or(wixData.query('Client_Info').contains('rowNumber', $w('#searchInput').value))
.find()
.then(res => {
$w('#table1').rows = res.items;
});
console.log("Dataset is searching for now " + $w('#searchInput').value);
}
$w("#dataset1").setSort( wixData.sort()
.ascending("date")
);