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!
Coming up next!
-
Webwinkel Vakdagen 2023
March 29 - 30, 2023 Team Yoast is Webwinkel Vakdagen 2023, click through to see if we'll be there, who will be there and more! See where you can find us next » -
Yoast SEO news webinar - March 28, 2023
28 March 2023 Our head of SEO, Jono Alderson, will keep you up-to-date about everything that happens in the world of SEO and WordPress. All Yoast SEO webinars »
sorttable.js is not working in mozila browser but it’s working in internet explorer give me the solution
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.
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.
I love this script! Is it possible to make a columm sorted by default?
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.
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
Joost,
If you add the statement
date = trim(date);
at the beginning of the function function sort_date(date)
it works for me now.
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
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?
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.
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
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
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?
You’re absolutely right, that’s a typo.
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]+)?%?$/