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] Value for properties of datatype Quantity are not sorted properly #571

Closed
osnard opened this issue Mar 12, 2020 · 3 comments
Closed

Comments

@osnard
Copy link
Contributor

osnard commented Mar 12, 2020

Setup

  • MW version: 1.34.0
  • DB (MySQL etc.): 10.2.12-MariaDB-10.2.12+maria~jessie
  • PHP version: 7.2.24-0ubuntu0.18.04.1 (fpm-fcgi)
  • SMW version: 3.1.5
  • SRF version: 3.1.0

Issue

When using a format=datatables with a query that contains a printout for a property of type "Quantity", the respective column is sorted as string instead of number.

Steps to reproduce

(recommendation is to use the sandbox)

  1. Create the following pages:
  • "Property:SomeProp": [[Has type::Quantity]][[Corresponds to::1 €]]
  • "Test_001": [[SomeProp::150]]
  • "Test_002": [[SomeProp::200]]
  • "Test_003": [[SomeProp::1000]]
  1. Create ASK query:
{{#ask:[[SomeProp::+]]
|?SomeProp
|format=datatables
}}
  1. Sort column "SomeProp"

Expected result: ...
Order should be: Test_001/150€ - Test_002/200€ - Test_003/1000€

Observed result: ...
Order is: Test_003/1000€ - Test_001/150€ - Test_002/200€

Hints
The jQuery DataTables widget seems to support currency-sorting. Unfortunately SMW has no concept of that is a currency. It only knows about "Quantity". But maybe columns of type quantity can have a generic sorter that just strips any unit from the value, thus making it a number again

@kghbln kghbln changed the title Format datatable does not properly sort values of type currency [Datatable] Value for properties of datatype Quantiy are not sorted properly Mar 24, 2020
@kghbln kghbln changed the title [Datatable] Value for properties of datatype Quantiy are not sorted properly [Datatables] Value for properties of datatype Quantiy are not sorted properly Mar 24, 2020
@kghbln
Copy link
Member

kghbln commented Mar 24, 2020

Thanks for reporting. Yeah, support for this would be great.

@kghbln kghbln changed the title [Datatables] Value for properties of datatype Quantiy are not sorted properly [Datatables] Value for properties of datatype Quantity are not sorted properly Mar 24, 2020
@osnard
Copy link
Contributor Author

osnard commented Apr 2, 2020

Btw.: it looks like "date" values are also not properly sorted.

@krabina
Copy link
Contributor

krabina commented Feb 3, 2023

I cannot confirm this. In our latest version, both sorting of dates and quantities is working fine.
You can see it here: https://silver.knowledge.wiki/User:Admin/Datatables_test
Both dates and weight are sorting fine.

Thus I suggest closing this (our PR has been merged with SRF already, the latest open one is only concerning caching).

@krabina krabina closed this as completed Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants