Hi,
I have a dataset in a table with filters, each row leads to a dynamic page. On each dynamic page I have a button who goes back to the table filtered before, to accomplish that I use memory.setItem for each dropdown value. This works fine. Now I have a button who clears all filters to start a new search, so I use memory.clear() to empty the stored values for the filters. But somehow clicking on the reset button, the items stored still get set as the placeholder text even though the table is not filtered. Which causes side effects if a new search is done.
I've tried several ways to do this but none seem to work. My site is www.segamacusers.com and this is the code for the reset button:
export function StateClr_click(event) { memory.clear() memory.setItem("Model", null) memory.setItem("Trans", null) memory.setItem("Year", null) memory.setItem("Location", null) memory.setItem("Taller", null) memory.setItem("State", null) memory.setItem("Status", null) function count() { let total = $w('#Disponibilidad').getTotalCount(); if (total > 0) { $w('#text84').text = total.toString(); } else { $w('#text84').text = "No result found."; } } $w('#Disponibilidad').onReady(() => { $w('#Disponibilidad').setFilter(wixData.filter().isNotEmpty("numMach")) .then(count); UniqueDropDownStateAll() UniqueDropDownWorkshopAll() UniqueDropDownModelAll() UniqueDropDownTransmAll() UniqueDropDownYearAll() UniqueDropDownLocAll() UniqueDropDownStatusAll() $w('#Statedropdown').value = null $w('#Statedropdown').selectedIndex = null; $w("#ModDropdown").value = null $w("#ModDropdown").selectedIndex = null $w('#TransDropdown').value = null $w('#TransDropdown').selectedIndex = null $w('#LocationDropdown').value = null $w('#LocationDropdown').selectedIndex = null $w('#StatusDropdown').value = null $w('#StatusDropdown').selectedIndex = null $w('#TallerDropdown').value = null $w('#TallerDropdown').selectedIndex = null $w('#YearDropdown').value = null $w('#YearDropdown').selectedIndex = null console.log($w('#Statedropdown').value) console.log($w('#ModDropdown').value) console.log($w('#TransDropdown').value) console.log($w('#LocationDropdown').value) console.log($w('#StatusDropdown').value) console.log($w('#TallerDropdown').value) console.log($w('#YearDropdown').value) })
Thanks in advance!
First of all, the onReady() event handler for the dataset is only needed when you need to perform some actions right after the dataset is ready. It's incorrect to use it in a button (or other) event handler).
Since you are using memory.clear(), you don't need to set all of the memory items to null.
To reset your dataset filter, you also need to clear the dataset's filter like this:
$w("#Disponibilidad").setFilter( wixData.filter() );