I have search capabilities and onclick filter/sort functions active on my site, but how do you reset the table to the default Dataset?
I want to create button that will remove all sorts, filters and queries made onClick, as to bring the table back to the default display, that’s specified in the editor dataset.
Example:
clicks filter button
or
uses search bar
=
filtered table results
then
click All Videos button
=
returns to default display before filtering/sorting/query.
I would make a function that clears this by setting setFilter, sorting on the dataset back to the state you have that is view all.
You should be able to do something like this to clear your sorts and filters:
$w("#myDataset").setFilter( wixData.filter() );
$w("#myDataset").setSort( wixData.sort() );
Sweet, Thanks! That works great for my filter and sort buttons! Here’s the code if anyone needs it.
// clear sorts and filters to default
export function ClearSortsFiltersButton_onClick(event) {
console.log("Attempting to clear sorts and filters");
$w("#myCollection").setFilter( wixData.filter() )
.then( () => {
console.log("Dataset is now filtered to default");
} );
$w("#myCollection").setSort( wixData.sort().descending('myField'))
.then( () => {
console.log("Dataset is now sorted to default");
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
}
I still can’t seem to figure out how to remove/clear a query onClick though. :S
Well, if you want to change the query itself (like to a different collection for example), you probably should look into using the wix-data query( ) function along the the table’s rows property to populate your table instead of using a dataset. With a dataset, you don’t have direct access to the query that gets its items.
Ah okay, that’s what I was trying to do originally but the queries mess with my filter and sort buttons. Oh well, looks like I’m just going to create a separate page for searching for now.
Thanks for the assistance!
Much Appreciated xx
is there no video on how to make these sort buttons? ive been looking for like 3 days , if some1 makes a tutorial of this and then code comes out , they would get alot of traffic on youtube XD
GCC - see above - how about uploading a short video that explains what you did?
you are guaranteed one like from me if you do it 
dude you are guaranteed a like share and comment from me XD
Hey, I think I can do that. 
let us know when you have 
Sorry it took a few days, work and life, ya know… lol
Here it is!
This creates issues. It will clear the searches, but then any subsequent searches will only work in dropdown that was previously used. If you go to another dropdown that was not used before the clear, then it will not function
Thank you so much, you kinda saved me 