Support » Plugin: TablePress » ColumnFilterWidgets Dropdown numbers not sorted correctly

  • Resolved mediaworker

    (@mediaworker)


    Hi,

    i have a table with a column only containing numbers. For example:

    100
    40
    50
    60
    500
    300
    1000
    150
    250

    I’ve activated the column sorting via datatables javascript feature.

    If I click on the column header the numbers are sorted correctly:
    40
    50
    60
    100
    150
    250
    300
    500
    1000

    I also have the ColumnFilterWidgets Plugin installed.

    The issue now is, that the dropdown of the column filter widget is displaying the numbers in this order:

    100
    150
    1000
    250
    300
    40
    50
    500
    60

    I already tried “columnDefs”: [ { “type”: “num”, “targets”: [ 4 ] ]

    But the dropdown is still sorted wrong.

    I hope somebody can help me with this issue 🙂

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I know what you mean, but unfortunately, at this time, it’s not possible to sort the dropdown menus, sorry 🙁

    Regards,
    Tobias

    Hi Tobias,

    thank you very much for your fast response.

    But shouldn’t the dropdowns containing numbers be sorted by numbers?

    The engine versions in the following example are sorted correctly, why not my simple list of numbers?

    https://legacy.datatables.net/extras/thirdparty/ColumnFilterWidgets/DataTables/extras/ColumnFilterWidgets/

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    the “Engine Version” in that link is actually also sorted as text, if you look closely.
    Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Hi Tobias,

    [ See first post ]

    Columns Speicherplatz and RAM for example.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for the link, I had missed it in the first post…

    These columns show the problem nicely! They are not plain numbers, but have text in them (like GB and so on). Due to this, the values are sorted as text strings and not as numbers. Unfortunately, I don’t know a way to change this in the dropdowns.

    One idea for a workaround would be to add extra columns to your table, that we hide e.g. with CSS code. In those columns, you would only put the number, without the GB and so on. Then, you could use the datatables_columnfilterwidgets_exclude_columns Shortcode parameter that is mentioned on the Extension’s web page at https://tablepress.org/extensions/datatables-columnfilterwidgets/ to hide the dropdowns with the wrong sort order.

    Regards,
    Tobias

    Hi Tobias,

    thanks for the suggestion but thats what I’m already doing. I have two columns for Speicherplatz. One with GB and another without GB. If you click on the column title “Speicherplatz” you’ll see that it sorts nicely. It simply doesn’t sort the dropdown correctly.

    I’m already using this:
    [table id=2 filter=”gep||pre” datatables_columnfilterwidgets=”true” datatables_columnfilterwidgets_exclude_columns=”1,4″ responsive=”scroll” /]

    and the custom commands:
    “columnDefs”: [ { “orderData”: [ 4 ], “targets”: [ 3 ] }, { “visible”: false, “targets”: [ 4 ] }, { “type”: “num”, “targets”: [ 4 ] } ]

    Very strange…

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ah, I see, I hadn’t realized that. Unfortunately, I don’t really know a solution here then 🙁 Sorry. You’d most likely have to modify the JS code of the ColumnFilterWidgets script then.

    Regards,
    Tobias

    Hi Tobias,

    okay, thank you very much!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem! Sorry that I could not offer a solution here.

    Regards,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.