Topic: Sort table by dates

Daniel Orte free asked 5 years 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!


shadsnz free answered 5 years 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 commented 5 years 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 free commented 4 years ago

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

Regards

Jarek


Jakub Chmura staff commented 4 years ago

@Jarek Jóźwik,

It's already implemented.

Best, Kuba


Jarek Jóźwik free commented 4 years 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 commented 4 years 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 free commented 4 years 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 free commented 4 years ago

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


Jarek Jóźwik free commented 4 years ago

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


Jakub Chmura staff commented 4 years 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


Rodrigo Pedro Zeballos Torres free commented 2 years ago

this already has a solution?


Krzysztof Wilk staff commented 2 years ago

As you can see above - you can sort data by date as a string or write and use a custom sorting function, where you can convert string type into a Date one. I'm afraid there are no changes in that functionality :(


Jakub Mandra staff answered 5 years 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



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.11.0
  • Device: Web
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: Yes