Hi!
I need my dataset to show the results ranked by date, from Old-->New.
The thing is, that when this Rank is set to rank from the New-->Old, the first results to appear are the most recent dates. But when i set to rank by date from Old-->New the first dates to appear are the EMPTY dates.... which makes no sense.
I tried to set the dateset filter by condition "not empty", but it does not has that option. In fact, in the editor, it does not allow us to set filter by date in the dataset (which is possible to do that manualy in the Database screen in the user "desktop", as seen in the print below).
Any sugestions on how can I set my dataset to show the results ranked by date, from Old-->New?
Hi Felipe
I believe your Date field's type is Date&Time, as a result, in order to filter it so that empty fields won't be shown, and also sort it from old to new, code is required.
Go to the dataset's properties and add an event handler that runs when the element is ready.
At the function's handler write the follow code:
export function dataset_ready_1() { $w("#dataset1").setFilter(wixData.filter() .isNotEmpty("date")) .then(() => { $w("#dataset1").setSort(wixData.sort() .ascending("date") ) }) }
The ascending() function refines a WixDataQuery or WixDataSort to sort in ascending order of the specified properties, and you can also sort type like date and time.
Here, you can read more about this function.
Have a nice day, and best of luck!
Sapir
Hi Felipe,
In order to sort your items according to your own Date field or according to the Default Created Date wix-Field go to sort options in the dataset's settings.
Have a nice day and best of luck!
Sapir