[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-24 Thread MorningZ

Never said it was a "ready for production with a zillion rows"... just
call it a "proof of concept" that tablesorter is *very* flexible, in
fact I would call it the most flexible plugin I've seen in the 15
months or so i've been into jQuery..   given more time, and the
need for me to use it, that parser could be tightened up..

in the end though, what I would do if i was presented with the problem
of "putting null rows at the bottom" is do this when the table is
generated from the server code (PHP, CF, .NET, etc) and put them into
the ... then the table would look the same plus tablesorter
would leave them alone


On Mar 24, 4:49 am, aquaone  wrote:
> impressive but has some flaws (large numbers, sorting w/o clicking headers,
> etc). not a complete fix but definitely a 95+% solution -- neat!
>
> aquaone
>
> On Tue, Mar 24, 2009 at 00:00, MorningZ  wrote:
>
> > Not the prettiest code i've ever written, but:
>
> > 1) It works :-)
> > 2) Didn't touch one single character in tablesorter.js
>
> >http://paste.pocoo.org/show/109306/
>
> > (Make sure you are viewing it in Firefox with FireBug going, or
> > comment out the "console.log"-s and set Tablesorter's option of
> > "debug" to "false")
>
> > On Mar 24, 12:30 am, Flight553  wrote:
> > > > you were on the right track with the ".addParser" method but there's
> > > > no need to edit it inside the core code
>
> > > Ok, I'll bite. How? addParser() just lets you determine one value that
> > > goes to sortnumeric(a, b) or sorttext(a, b). Those methods are
> > > designed to put a value on top when sorting one direction, and on
> > > bottom when sorting the other direction. How can you get a value to
> > > always be sorted to the bottom using addParser?
>
> > > I know the patching I offered sucked, but don;t know how else to do it
> > > with the tablesorter.js code as exists.
>
> > > Suggestions?


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-24 Thread aquaone
impressive but has some flaws (large numbers, sorting w/o clicking headers,
etc). not a complete fix but definitely a 95+% solution -- neat!

aquaone


On Tue, Mar 24, 2009 at 00:00, MorningZ  wrote:

>
> Not the prettiest code i've ever written, but:
>
> 1) It works :-)
> 2) Didn't touch one single character in tablesorter.js
>
> http://paste.pocoo.org/show/109306/
>
> (Make sure you are viewing it in Firefox with FireBug going, or
> comment out the "console.log"-s and set Tablesorter's option of
> "debug" to "false")
>
>
>
>
> On Mar 24, 12:30 am, Flight553  wrote:
> > > you were on the right track with the ".addParser" method but there's
> > > no need to edit it inside the core code
> >
> > Ok, I'll bite. How? addParser() just lets you determine one value that
> > goes to sortnumeric(a, b) or sorttext(a, b). Those methods are
> > designed to put a value on top when sorting one direction, and on
> > bottom when sorting the other direction. How can you get a value to
> > always be sorted to the bottom using addParser?
> >
> > I know the patching I offered sucked, but don;t know how else to do it
> > with the tablesorter.js code as exists.
> >
> > Suggestions?
>


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-24 Thread MorningZ

Not the prettiest code i've ever written, but:

1) It works :-)
2) Didn't touch one single character in tablesorter.js

http://paste.pocoo.org/show/109306/

(Make sure you are viewing it in Firefox with FireBug going, or
comment out the "console.log"-s and set Tablesorter's option of
"debug" to "false")




On Mar 24, 12:30 am, Flight553  wrote:
> > you were on the right track with the ".addParser" method but there's
> > no need to edit it inside the core code
>
> Ok, I'll bite. How? addParser() just lets you determine one value that
> goes to sortnumeric(a, b) or sorttext(a, b). Those methods are
> designed to put a value on top when sorting one direction, and on
> bottom when sorting the other direction. How can you get a value to
> always be sorted to the bottom using addParser?
>
> I know the patching I offered sucked, but don;t know how else to do it
> with the tablesorter.js code as exists.
>
> Suggestions?


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-23 Thread Flight553


> you were on the right track with the ".addParser" method but there's
> no need to edit it inside the core code

Ok, I'll bite. How? addParser() just lets you determine one value that
goes to sortnumeric(a, b) or sorttext(a, b). Those methods are
designed to put a value on top when sorting one direction, and on
bottom when sorting the other direction. How can you get a value to
always be sorted to the bottom using addParser?

I know the patching I offered sucked, but don;t know how else to do it
with the tablesorter.js code as exists.

Suggestions?


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-23 Thread MorningZ

"I don't think a custom parser can "always force null data to the
bottom."

Maybe it's outside your skill level, but it is *definitely* do-able
without touching one single character of code inside tablesorter.js

you were on the right track with the ".addParser" method but there's
no need to edit it inside the core code



On Mar 23, 3:28 pm, Ptang  wrote:
> On Mar 13, 5:52 am, MorningZ  wrote:
>
> > A custom parser would *definitely* handle this
>
> I don't think a custom parser can "always force null data to the
> bottom."
>
> The custom parsers just normalize cell contents into "numeric" or
> "text" format and that result is then sent on to the sorting routine.
> This means that if you use a custom parser to set a null data  (or "*"
> or "n/a") to be treated as "z" (text) or  (numeric) then
> those cells will be pushed to the bottom for ASCENDING sorts. But when
> a user clicks the th header again for DESCENDING sorts, then those
> cells with null data will be on top.
>
> I think the point of the original question was that when there is no
> data in a cell, that cell is irrelevant/useless to any sorting, and
> therefore should ALWAYS be pushed to the bottom of the column.
>
> The only way to do that at this stage is to patch
> jquery.tablesorter.js in 3 places (assuming that cells with only '-'
> are the "null" ones):
>
>       ts.addParser({
>           id: /* choose an existing numeric parser to
> edit, or create a new one **/
>           format: function(s) {
> +             if(s == '-') return "0.000"; // flags this float for
> sortNumeric() as string type, while type juggling will treat as zero
>
>       function sortNumeric(a,b) {
> +         if(a === '0.000') return 1;  // tests for string type set by
> numeric Parser, means this cell has the '-'
> +         else if(b === '0.000') return -1; // force cells with just
> "-" always to bottom
>           return a-b;
>
>       function sortText(a,b) {
> +         if(a == '-') return 1;
> +         else if(b == '-') return -1; // force cells with just "-"
> always to bottom
>           return ((a < b) ? -1 : ((a > b) ? 1 : 0));
>
> It is a bad hack, but is the best I can do to always force empty cells
> or cells with no data to the bottom of the sorted column.


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-23 Thread Ptang



On Mar 13, 5:52 am, MorningZ  wrote:
> A custom parser would *definitely* handle this



On Mar 13, 5:52 am, MorningZ  wrote:
> A custom parser would *definitely* handle this

I don't think a custom parser can "always force null data to the
bottom."

The custom parsers just normalize cell contents into "numeric" or
"text" format and that result is then sent on to the sorting routine.
This means that if you use a custom parser to set a null data  (or "*"
or "n/a") to be treated as "z" (text) or  (numeric) then
those cells will be pushed to the bottom for ASCENDING sorts. But when
a user clicks the th header again for DESCENDING sorts, then those
cells with null data will be on top.

I think the point of the original question was that when there is no
data in a cell, that cell is irrelevant/useless to any sorting, and
therefore should ALWAYS be pushed to the bottom of the column.

The only way to do that at this stage is to patch
jquery.tablesorter.js in 3 places (assuming that cells with only '-'
are the "null" ones):


  ts.addParser({
  id: /* choose an existing numeric parser to
edit, or create a new one **/
  format: function(s) {
+ if(s == '-') return "0.000"; // flags this float for
sortNumeric() as string type, while type juggling will treat as zero



  function sortNumeric(a,b) {
+ if(a === '0.000') return 1;  // tests for string type set by
numeric Parser, means this cell has the '-'
+ else if(b === '0.000') return -1; // force cells with just
"-" always to bottom
  return a-b;


  function sortText(a,b) {
+ if(a == '-') return 1;
+ else if(b == '-') return -1; // force cells with just "-"
always to bottom
  return ((a < b) ? -1 : ((a > b) ? 1 : 0));


It is a bad hack, but is the best I can do to always force empty cells
or cells with no data to the bottom of the sorted column.


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-23 Thread Ptang



On Mar 13, 5:52 am, MorningZ  wrote:
> A custom parser would *definitely* handle this

I don't think a custom parser can "always force null data to the
bottom."

The custom parsers just normalize cell contents into "numeric" or
"text" format and that result is then sent on to the sorting routine.
This means that if you use a custom parser to set a null data  (or "*"
or "n/a") to be treated as "z" (text) or  (numeric) then
those cells will be pushed to the bottom for ASCENDING sorts. But when
a user clicks the th header again for DESCENDING sorts, then those
cells with null data will be on top.

I think the point of the original question was that when there is no
data in a cell, that cell is irrelevant/useless to any sorting, and
therefore should ALWAYS be pushed to the bottom of the column.

The only way to do that at this stage is to patch
jquery.tablesorter.js in 3 places (assuming that cells with only '-'
are the "null" ones):


  ts.addParser({
  id: /* choose an existing numeric parser to
edit, or create a new one **/
  format: function(s) {
+ if(s == '-') return "0.000"; // flags this float for
sortNumeric() as string type, while type juggling will treat as zero



  function sortNumeric(a,b) {
+ if(a === '0.000') return 1;  // tests for string type set by
numeric Parser, means this cell has the '-'
+ else if(b === '0.000') return -1; // force cells with just
"-" always to bottom
  return a-b;


  function sortText(a,b) {
+ if(a == '-') return 1;
+ else if(b == '-') return -1; // force cells with just "-"
always to bottom
  return ((a < b) ? -1 : ((a > b) ? 1 : 0));


It is a bad hack, but is the best I can do to always force empty cells
or cells with no data to the bottom of the sorted column.


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-13 Thread MorningZ

A custom parser would *definitely* handle this

I could write it up if i had an example of the HTML

On Mar 12, 6:45 pm, Big Mad Kev  wrote:
> Yep thats it basic numeric sort with nulls on bottom.
>
> From what I have read I don't think a parser will help unless I've
> misunderstood
>
> Thanks for your quick reply.
>
> On Mar 12, 10:08 pm, aquaone  wrote:
>
> > You could define your own parser to do this. Are you looking for a basic
> > numeric sort with nulls on bottom? lexicographical sort? ..?
>
> > stephen
>
> > On Thu, Mar 12, 2009 at 11:52, Big Mad Kev  wrote:
>
> > > Good Morning / Afternoon / Evening,
>
> > > Using the tableSorter does anyone know if it's possible to all ways
> > > force null / empty / 0 Digit cells to always be at the bottom, The
> > > solution I have is to have additional columns with either 0/1 for
> > > ASC / DEC Sorts and sorting on that first.
>
> > > But I need a more elegant way, I'm sure it's possible but I have tried
> > > everything I can think off.
>
> > > Any help is appreacited
>
> > > TIA
>
> > > Kev


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-12 Thread Big Mad Kev

Yep thats it basic numeric sort with nulls on bottom.

>From what I have read I don't think a parser will help unless I've
misunderstood

Thanks for your quick reply.

On Mar 12, 10:08 pm, aquaone  wrote:
> You could define your own parser to do this. Are you looking for a basic
> numeric sort with nulls on bottom? lexicographical sort? ..?
>
> stephen
>
> On Thu, Mar 12, 2009 at 11:52, Big Mad Kev  wrote:
>
>
>
> > Good Morning / Afternoon / Evening,
>
> > Using the tableSorter does anyone know if it's possible to all ways
> > force null / empty / 0 Digit cells to always be at the bottom, The
> > solution I have is to have additional columns with either 0/1 for
> > ASC / DEC Sorts and sorting on that first.
>
> > But I need a more elegant way, I'm sure it's possible but I have tried
> > everything I can think off.
>
> > Any help is appreacited
>
> > TIA
>
> > Kev


[jQuery] Re: tablesorter - Force Null / Empty Cells to the Bottom?

2009-03-12 Thread aquaone
You could define your own parser to do this. Are you looking for a basic
numeric sort with nulls on bottom? lexicographical sort? ..?

stephen


On Thu, Mar 12, 2009 at 11:52, Big Mad Kev  wrote:

>
> Good Morning / Afternoon / Evening,
>
> Using the tableSorter does anyone know if it's possible to all ways
> force null / empty / 0 Digit cells to always be at the bottom, The
> solution I have is to have additional columns with either 0/1 for
> ASC / DEC Sorts and sorting on that first.
>
> But I need a more elegant way, I'm sure it's possible but I have tried
> everything I can think off.
>
> Any help is appreacited
>
> TIA
>
> Kev
>