• Resolved sedohr7682

    (@sedohr7682)


    I use 2 or 3 character html link text in one of my cells. The character represent numeric data (price).

    http://smoothiemakershq.com/compare-smoothie-makers/

    The column will sort on the 1st char of the 2 character ‘value’ and therefore the column does not sort correctly. At first I thought it was because the cell has text and therefore is being sorted as a string rather than a numeric.

    However, I have a similar table running on another site that sorts the same type of data correctly. The only difference is this table has the same # of characters for each ‘price’.
    http://dysonvacuumreviewdude.com/compare-dyson-models/

    Does TablePress know a cell contains an html link and therefore sorts based ONLY on the link text? If so, is the data still considered a string for sorting purposes? That’s the only thing I can figure out is happening here.

    http://wordpress.org/extend/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    You are right. The DataTables JavaScript library does recognize that there’s HTML code in the cell, and then just sorts with the link text. However, it treats that as a string and not a number. That leads to to result that you are seeing.
    To fix this, please install and activate the TablePress Extension from http://tablepress.org/extensions/datatables-numhtml/
    After that, add this to the “Custom Commands” text field in the “Features of the DataTables JavaScript library” section on the “Edit” screen of the table from http://smoothiemakershq.com/compare-smoothie-makers/ :

    "aoColumnDefs": [ { "sType": "num-html", "aTargets": [ 2 ] } ]

    This will fix the data type for the third column of the table (there’s a 2 in the code, because counting starts with 0).

    Regards,
    Tobias

    Thread Starter sedohr7682

    (@sedohr7682)

    Perfect! Thanks Tobias…..

    Just FYI… wanted to give a small token of appreciation (in between jobs right now but your plugin/support is AWESOME!)but can’t send gift card w/o and email addy.

    Could not find it anywhere on your donate or amazon wishlist (US) page. ;o(

    Didn’t want to donate via PP and have them remove fees.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great to hear that this solved it 🙂

    And thanks for wanting to donate, I really appreciate it! 🙂
    For that gift card, please send me an email to the address that you can see on http://tablepress.org/imprint/ I will then send you the email address that I prefer for Amazon (because it is a different one). Thanks!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sorting html link text’ is closed to new replies.