Hello, I have a dynamic page displaying data within a repeater that is connected to my dataset within the content manager. I am trying to add a dropdown to my page that would allow a user to sort (A-Z, Z-A, Low-High, High-Low) the data based off of specific field keys within our dataset.
So far all I have found online is how to filter. There has been little to nothing about SORTING data. The only answers I have found with SORT involves sorting from the content manager. However, I need the user who is using my site to be able to sort the data that is displayed on the page for themselves.
Thanks in advance for you help.
https://www.nasriya . net/example/conditional-data-filtering?id=LtqxU28upJtrzP2x
Here are some code examples from Wix on how to create a sort for a dataset. Basically if you will be using a dropdown so that your website visitor selects an option to sort by, you need to create a function that triggers the correct sort code.
Thank you so much. Everyone has giving me answers on how to FILTER but what I really needed, as stated in my question, is how to SORT. Very much different functions. So thank you for finally pointing me in a good direction!
@joshjnunez09 No problem! Even I read the questions wrong sometimes — but when I always answer to best of my knowledge in hopes that my answer triggers something in the right direction
@code-queen So you’ve definitely pointed me in the right direction. This is my first time coding within the Wix / Velo interface so I’m not entirely certain of how it all works yet. However, i do know that what you told me seems to be a step closer in the right direction. I’ve created a dropdown element which i’ve connected to an event handler (onClick). Upon the user clicking one of the fields to sort by (A-Z, Capacity, Sq. Ft) the data within the repeater is manipulated on the page. But it is NOT correct. Explanation: the dataset in this repeater is for a list of venues. Upon clicking ‘sort by’ : ‘capacity’ the dataset changes order but it is not actually changing correctly because the capacity is not being listed in ascending order. or descending for that matter. It seems to be random. I see no pattern in the order so it makes it harder to debug. Do you think you could help by pointing me in the right direction again (: here’s a pic for reference
Nevermind, I figured out my problem. thanks again for your help!