Sortable table script updated to v1.5.5

I got an email from Mozilla’s director of product management Sherman Dickman today, that my sortable table script wasn’t sorting numbers above 1 million which have comma’s in them correctly (they do have a lot of Firefox downloads ;) ).

The problem was caused by the fact that replace only replaced items once, where they should be replaced multiple times. I don’t know where Sherman will be using the script yet, once I do I’ll of course tell you all about it!

Make Yoast SEO & Woo work together smoothly

  • Make your products stand out in Google
  • Get more buyers to your online store
  • Make products easier to find on your site
  • Have a cleaner XML sitemap & more
More info

15 Responses to Sortable table script updated to v1.5.5

  1. Tamil
    Tamil  • 11 years ago

    sorttable.js is not working in mozila browser but it’s working in internet explorer give me the solution

  2. leon
    leon  • 11 years ago

    I don’t know why but the solution from Robbert does work :)

    I’m using the script in a system and someone had some complaints about the date field and I changed i to 1 and it works.

    Thanks for the script.

  3. iGGy
    iGGy  • 11 years ago

    Hi. Loved this script. Works great and solved my alternate rows style problem. I have the same issue with Oasis. How to make the row number static instead of getting sorted along with the other columns?

    tQ.

  4. Klibb
    Klibb  • 11 years ago

    I love this script! Is it possible to make a columm sorted by default?

  5. Oasis
    Oasis  • 11 years ago

    When I sort the table the Serial Number field which is the first column of the table also gets sorted. How I can fix this. I don’t want to sort my serial number column.

    Thanks in advance.

  6. Robbert de Zeeuw
    Robbert de Zeeuw  • 11 years ago

    Joost,

    My former comment was not correct!!!

    In the function ts_resortTable(lnk, clid)

    I also changed the var i from 0 into 1 (see below). Be aware of the fact that I am not an html/javascript expert, so this solution may not be the correct one.

    if (t.rows.length

  7. Robbert de Zeeuw
    Robbert de Zeeuw  • 11 years ago

    Joost,

    If you add the statement

    date = trim(date);

    at the beginning of the function function sort_date(date)

    it works for me now.

  8. Robbert de Zeeuw
    Robbert de Zeeuw  • 11 years ago

    Joost,

    The script is cool, but … ;-)

    The sorting on a date column is not working as expected; even if you see your own tabel example, the years are not sorting correctly.

    Robbert

  9. Jeremy Brown
    Jeremy Brown  • 11 years ago

    First of all fantastic script.
    Works a treat and has dropped our server load dramatically as we had page reload sorting links before.

    One point is that all our table columns have resized to equal widths. A 5 column table will set all columns to 20% rather than the default size column based on size of content.

    We have tried applying widths to each column but this hasn’t helped.
    Is this a “feature” I can disable in the script or is it just part and parcel of using this sort of dynamic functionality on a static table?

  10. Eep²
    Eep²  • 11 years ago

    I have a very complicated table at http://tnlc.com/eep/compare/table.html I’d like to be able to sort, but your script doesn’t support sorting on either axis. I would like to be able to sort on the vertical axis, too, by game or feature (circa, genre, publisher, developer, etc). Also, the table has a lot of intricate column/row spanning that I’m not sure your script supports properly. As it is now, the table only sorts on the first column, screwing up majorly. :/ Can you take a look? Thanks. Oh and can the sort icons not replace existing graphics in the table cells? I had to create a separate empty table row.

  11. Ole
    Ole  • 11 years ago

    Okay, I have found out where the problem lies:
    if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)) sortfn = ts_sort_numeric;

    That line seems to take some dates as numbers and therefore destroys the ability of the script to sort dates. Should be changed.

    Regards

    Ole

  12. Ole
    Ole  • 11 years ago

    Hi!

    First of all, great work, saves a lot of time and work if somebody has already developed a solution for everything you need.

    But I have a problem: I have a table in which there are dates in the German date format (such as 22.01.1950, 11.02.1951 etc.), and the script only treats them as strings and sorts them “11.02.1951 is sorted before 22.01.1950 etc.”. That is not what your script promises (and what it is programmed to do, as I think) ;). So what’s the matter? Where is my fault?

    Thanks a lot!

    Ole

  13. paul
    paul  • 12 years ago

    I’ve been playing with sortable.js for a while on some tables I have and it works great except I can’t get it to sort number columns properly. It doesn’t seem to recognise my column as numeric and is instead searching by string (e.g. 3, 45, 9 rather than 3, 9, 45). I have the corrected JS above but still doesn’t work. Was there something special you need to do to make sure a column is viewed as number?

  14. Joost de Valk

    You’re absolutely right, that’s a typo.

  15. Anonymous
    Anonymous  • 12 years ago

    The script doesn’t work for me, I get a javascript error in your regexp in sortable.js (line 107):

    invalid quantifier +%?$

    The line is

    if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?+%?$/)) sortfn = ts_sort_numeric;

    Shouldn’t the regexp be

    /^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/


Check out our must read articles about WordPress