• Resolved kgagne

    (@kgagne)


    Hello!

    Previously, I would define my columns’ data types with these custom commands:

    "columns": [ { "type": "num" }, { "type": "date" }, { "type": "html"}, null, {"type": "num"} ]

    I recently noticed that tables I set up years ago were no longer sorting properly. Per this documentation, I rewrote the above command to as follows:

    "columnDefs": [ { "type": "num", "targets": [0,4] }, { "type": "date", "targets": [1] }, { "type": "html", "targets": [2] } ]

    The table is now sorting properly.

    When did this change become necessary? Do I need to update all my tables accordingly?

    -Ken

    • This topic was modified 7 years, 8 months ago by kgagne.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi Ken,

    I think this happened more than 2 years ago now, when the DataTables JS library updated its internal API and parameter format (when changing version from 1.9.x to 1.10.x). So, this was not a change by TablePress but in the external DataTablees JS library.
    However, both formats should actually still work, from what I know.
    See https://datatables.net/reference/option/columns.type and https://datatables.net/reference/option/columnDefs

    In the long run, the columnDefs should be better though.

    Regards,
    Tobias

    Thread Starter kgagne

    (@kgagne)

    Thanks, Tobias!

    I think my issue was with a specific format of date, as seen in this example —?sorting on the date column would produce an alphabetical list instead of a chronological one. Switching to columnDefs fixed it.

    I’ve now updated all my tables across all my sites to use this “new” (two-year-old!) format. ??

    -Ken

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    great! Good to hear that it’s working again!

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change in defining column data types’ is closed to new replies.