Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[datatables] Datatables should sort Quantity data numerically #831

Open
alistair3149 opened this issue May 3, 2024 · 3 comments · Fixed by #833
Open

[datatables] Datatables should sort Quantity data numerically #831

alistair3149 opened this issue May 3, 2024 · 3 comments · Fixed by #833
Labels

Comments

@alistair3149
Copy link
Contributor

Setup

  • MW version: 1.39.7
  • DB (MySQL etc.): 10.11.7-MariaDB-1:10.11.7+maria~ubu2204
  • PHP version: 8.1.28 (fpm-fcgi)
  • SMW version: 4.1.3
  • SRF version: 4.2.1

Issue

Quantity type properties are sorted alphabetically instead of numerically in datatable, which is unexpected by the users.

Steps to reproduce

  1. Set up an inline ask query on a page
  2. Set format set as 'datatables'
  3. Add any properties with the Quantity type
  4. Save the page
  5. Click on the property in the table header to sort the column

Expected result:
The datatable should be sorted by that property numerically.

Observed result:
The datatable is sorted by that property alphabetically.

Example page with the issue: https://starcitizen.tools/Gun
The Damage, Range, and Muzzle velocity properties have the Quantity type.

@alistair3149
Copy link
Contributor Author

The latest commit did not fix the issue for us.
Perhaps any-number have troubles with units and number separators?

@krabina krabina reopened this May 7, 2024
@alistair3149
Copy link
Contributor Author

Hmm in that case, may I suggest inserting a data-order attribute using the raw number output of the SMW property (#-n) into the <td>element? That should resolve all the quantity sorting issue.

@alistair3149
Copy link
Contributor Author

alistair3149 commented Sep 3, 2024

Just an update, datatables handles the unit correctly, but it cannot sort numbers with separators correctly. It seems that the numerical sorting stop at the first separator.
image

It appears that the datatable doesn't sort date correctly as well. The dates are being sorted alphabetically instead of sorting by recency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants