Discussion:
Table sorting alternatives?
Charles Capps
2007-02-02 18:46:29 UTC
Permalink
Either my Google-fu is weak, or the TableSorter plugin appears to be the
only game in town for table sorting in jQuery-land:
http://motherrussia.polyester.se/jquery-plugins/tablesorter/

Now, don't get me wrong, it works perfectly fine (when not trying to
stripe a 1600 row table), but it lacks a feature that I need for my
particular data set - multi-column sorting, or at a minimum, using
another column as a tie-breaker. The data I'm dealing with is half
zeros, and half non-zeros, and users have expressed annoyance that all
the rows with zeros end up in an unuseful order when they sort by that
column.

I've determined that it would be nigh-impossible to wedge in any sort of
consideration of multiple columns in the existing plugin. It puts
together all the data from one column before throwing it at the sort
routine, and the sort routine itself is utterly unaware that there's
anything outside of the current data set to look at, rightfully so.

So before I set out to try and solve the problem (or switch back to
server-side sorting, eww), does anyone already have a table sorting
plugin for jQuery that can handle multiple column sorting, or that can
use a second column as a tie-breaker?

Thanks!
sunsean
2007-02-02 18:57:55 UTC
Permalink
One minor solution is to sort by the second column first, then sort by the
first column. As long as the sorts build on each other, this should achieve
the same effect. I'm not sure if TableSorter stores the sorted result, or
just sorts the original, but it would be an easy fix to your problem.

~Sean
Charles Capps
2007-02-02 19:09:21 UTC
Permalink
Post by sunsean
One minor solution is to sort by the second column first, then sort by
the first column. As long as the sorts build on each other, this
should achieve the same effect. I'm not sure if TableSorter stores the
sorted result, or just sorts the original, but it would be an easy fix
to your problem.
~Sean
Unfortunately TableSorter can only think about one column at a time,
which is the core problem. I'm not sure if it stores the result of the
sort or the data to be sorted, but it does have some variety of data
caching. This cached data, however, does not appear to be reachable
from within the sort routine, which appears to be unaware of anything in
the outside world.
Christian Bach
2007-02-02 20:08:29 UTC
Permalink
Hi,

Actually i have been playing around with two column sorting a while back,
the design of the plugin is in fact a bit stupid since it builds strictly
around one column sorting (it was originally designed just for speed and the
fun of it all). The built in sorting of Arrays in javascript is a bit let's
just call it limited. A two column sorting function basically just check if
a condition is true / false, if false it would need to send the current
array to the next sorting function. I will see if i have the time and
patience to introduce two column sorting in a upcoming release.

Best regards
Christian Bach
Post by Charles Capps
Either my Google-fu is weak, or the TableSorter plugin appears to be the
http://motherrussia.polyester.se/jquery-plugins/tablesorter/
Now, don't get me wrong, it works perfectly fine (when not trying to
stripe a 1600 row table), but it lacks a feature that I need for my
particular data set - multi-column sorting, or at a minimum, using
another column as a tie-breaker. The data I'm dealing with is half
zeros, and half non-zeros, and users have expressed annoyance that all
the rows with zeros end up in an unuseful order when they sort by that
column.
I've determined that it would be nigh-impossible to wedge in any sort of
consideration of multiple columns in the existing plugin. It puts
together all the data from one column before throwing it at the sort
routine, and the sort routine itself is utterly unaware that there's
anything outside of the current data set to look at, rightfully so.
So before I set out to try and solve the problem (or switch back to
server-side sorting, eww), does anyone already have a table sorting
plugin for jQuery that can handle multiple column sorting, or that can
use a second column as a tie-breaker?
Thanks!
_______________________________________________
jQuery mailing list
http://jquery.com/discuss/
Charles Capps
2007-02-02 22:49:22 UTC
Permalink
Thank you for the update, Christian. Seeing the "official" solution
have two column sorting would be beautiful, as the rest of the
functionality is well done.
Post by Christian Bach
Hi,
Actually i have been playing around with two column sorting a while
back, the design of the plugin is in fact a bit stupid since it builds
strictly around one column sorting (it was originally designed just for
speed and the fun of it all). The built in sorting of Arrays in
javascript is a bit let's just call it limited. A two column sorting
function basically just check if a condition is true / false, if false
it would need to send the current array to the next sorting function. I
will see if i have the time and patience to introduce two column sorting
in a upcoming release.
Best regards
Christian Bach
Either my Google-fu is weak, or the TableSorter plugin appears to be the
http://motherrussia.polyester.se/jquery-plugins/tablesorter/
Now, don't get me wrong, it works perfectly fine (when not trying to
stripe a 1600 row table), but it lacks a feature that I need for my
particular data set - multi-column sorting, or at a minimum, using
another column as a tie-breaker. The data I'm dealing with is half
zeros, and half non-zeros, and users have expressed annoyance that all
the rows with zeros end up in an unuseful order when they sort by that
column.
I've determined that it would be nigh-impossible to wedge in any sort of
consideration of multiple columns in the existing plugin. It puts
together all the data from one column before throwing it at the sort
routine, and the sort routine itself is utterly unaware that there's
anything outside of the current data set to look at, rightfully so.
So before I set out to try and solve the problem (or switch back to
server-side sorting, eww), does anyone already have a table sorting
plugin for jQuery that can handle multiple column sorting, or that can
use a second column as a tie-breaker?
Thanks!
_______________________________________________
jQuery mailing list
http://jquery.com/discuss/ <http://jquery.com/discuss/>
------------------------------------------------------------------------
_______________________________________________
jQuery mailing list
http://jquery.com/discuss/
Continue reading on narkive:
Loading...