Sort table by dates

web
mobile

Topic: Sort table by dates

Daniel Orte asked a year ago

I'd like to sort a table by dates, but not sorting "string" dates as with this format YYYY/MM/DD (as a basic example here: https://mdbootstrap.com/docs/react/tables/search/), I'd like to sort by date format as MM/DD/YYYY. Is there any way to do that?

Separate note: in this basic example (https://mdbootstrap.com/docs/react/tables/search/) the column salary in the table shows differents values than the code below.

Thanks!


Jakub Mandra staff premium answered a year ago

Hi,

Unfortunately, it is not possible to attach your custom sorting function, or sorting rules to the DataTable header.

But you could write your own sorting function and just sort your table data.

We are going to upgrade the component, so such functionality will be considered.

Best,

Jakub


shadsnz answered a year ago

I'd also like to see this functionality added.

Being able to sort so that 2-May-2018 comes after 3-Jan-2018 would be very useful.


Jakub Mandra staff premium commented a year ago

Hi,

This is under the development right now, so we should be able to release that feature soon (there is no estimated date yet).

Best,

Jakub


Jarek Jóźwik commented 7 months ago

Hello, has there been any progress on sorting columns with date in various formats?

Regards

Jarek


Jakub Chmura staff premium commented 7 months ago

@Jarek Jóźwik,

It's already implemented.

Best, Kuba


Jarek Jóźwik commented 7 months ago

So sorting dates in format like 10-05-2015, 15-07-2018 should work? Cause I've just changed how dates are displayed in my tables, from Y-m-d to d-m-Y and it sorted them in a way 1-01-2015, 2-01-2014, 3-06-2017 - meaning days sorted, but then not months and years. Version I've downloaded is: Version: MDB FREE 4.9.0 Is this sorting feature with dates working in paid version only? Thanks


Jakub Chmura staff premium commented 7 months ago

It's an old version. We currently published 4.23.1, Try with a new version. I describe how to sort by value here:

https://mdbootstrap.com/support/react/sorting-problem-with-new-date/

Best, Kuba


Jarek Jóźwik commented 7 months ago

downloading as typing. I have downloaded package from here on 19/11, no idea how I ended up with older version.


Jarek Jóźwik commented 7 months ago

Current version for download is 4.10.1 - what I'm missing here?


Jarek Jóźwik commented 7 months ago

Ahh I can see - it's for react. I don't use it, just regular jquery/bootstrap version.


Jakub Chmura staff premium commented 7 months ago

Nice to see that you solved your problem,

If there is anything else I could do for you do not hesitate to ask me. I'll be happy to help you.

Best Regards,

Kuba


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: React
  • MDB Version: 4.11.0
  • Device: Web
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: Yes