Topic: basic datatables sort not working

Earle premium asked 2 years ago


The table should sort asc and desc by integer value. Even the example of the mdb site doesn't work. The last column for salary does not order in descending order, even if you remove the dollar symbol.

It seems to treat everything as a string so 29 is higher than 118. Is there an attribute that can be added to the td to fix this?

If I remove mtb and just use jquery it works fine.


Earle premium answered 2 years ago


okay that makes sense, thanks


Kamila Pieńkowska staff answered 2 years ago


If you declare datatable with data-attribute, content of every cell will be of type string. If you want datatable to properly sort dates or numbers you need to input your data via JS or alternatively with jQuery as you did.



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 6.0.1
  • Device: MacBook Pro
  • Browser: Chrome
  • OS: Big Sur
  • Provided sample code: No
  • Provided link: No