Hi, I have a dynamic category page for a dataset with data displayed in a repeater. Users are able to filter the data displayed using multiple drop downs. I need a 'clear filters' button, or even just a button that will reload the whole page - but I can't for the life of me work out how to do this.
I've tried wixLocation.to(url) - with no luck, the page goes back to the top as if it's refreshing, but the dataset and filters don't reset.
I've tried $w("#dataset").refresh() - this doesn't seem to do anything at all
I've tried to reset each dropdown box to 0 i.e. $w("#dropdown1").selectedIndex = 0; - this resets the placeholder text in the dropdown to the first option, but the repeater remains filtered.
I've also tried just linking the button to the page url - but this still doesn't refresh the filters??
When I manually refresh the page (i.e. command+r), the page AND the filters refresh. How can I get a button to perform this function?
Thanks in advance :)
So I have 2 dropdown boxes that filter a repeater and just added a 'View All' button to refresh the filters & show all the repeater items. The above code worked and reset the filters and it shows all the repeater items, but when you go to use the dropdown filters again, it won't filter the repeater anymore. Is there a way to get the dropdown filters to work again after the 'View All' button is pushed?
Here's my current code:
export function button14_click(event) { $w('#dataset1').setFilter(wixData.filter()); $w('#dropdown4').value = "Specialty"; $w('#dropdown5').value = "State"; $w('#dropdown4').resetValidityIndication(); $w('#dropdown5').resetValidityIndication();
}
This worked perfectly! Thanks so much :)
You can reset the filter using the code shown here in 'Clear a dataset's filters' example
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFilter
A basic reset code example below using valid calls in your code.
https://www.wix.com/corvid/reference/$w.ValidatableMixin.html
THE ELEMENTS The Page User Inputs: First Name Field: #input1 Last Name Field: #input2 Email Field: #input3 Phone Field: #input4 Button Element: Submit Button: #Submit Reset Button: #Reset The Database Create a database Courses (dataset1). Recommended fields: First Name ID: fname Last Name ID: lname Email ID: email Phone ID: phone Course Type ID: course Course Date ID: date Course Timing ID: time Email ID: email
Page Code // Reset Button // export function Reset_click(event, $w) { $w('#input1').value = ""; $w('#input2').value = ""; $w('#input3').value = ""; $w('#input4').value = ""; $w('#dropdown1').value = "Select Course"; $w('#dropdown2').value = "Select Timing"; // Reset validation - Otherwise fields will show error // $w('#input1').resetValidityIndication(); $w('#input2').resetValidityIndication(); $w('#input3').resetValidityIndication(); $w('#input4').resetValidityIndication(); $w('#dropdown1').resetValidityIndication(); $w('#dropdown2').resetValidityIndication(); }