Reputation: 213
I have a Tablesorter plugin on table, and it's nicely sorting on ascending and descending. If some cells are empty they are going to appear as first or last, according to settings.
However, if all cells in the column are empty it randomly sorts them! The expected behavior I want is not to do anything.
How can I implement this behavior?
Upvotes: 1
Views: 667
Reputation: 86403
Try out my fork of tablesorter. It has options to specifically sort spaces and text within a numeric column:
emptyTo
option (demo)String indicating how tablesorter should deal with empty table cells.
"bottom"
- sort empty table cells to the bottom."top"
- sort empty table cells to the top."none"
or "zero"
- sort empty table cells as if the cell has the value equal to zero."emptyMax"
- sort empty table cells as having a value greater than the max (more positive) value."emptyMin"
- sort empty table cells as having a value greater than the min (more negative) value.stringTo
option (demo)A key word indicating how tablesorter should deal with text inside of numerically sorted columns.
"max"
will treat any text in that column as a value greater than the max (more positive) value."min"
will treat any text in that column as a value greater than the min (more negative) value."top"
will always sort the text to the top of the column."bottom"
will always sort the text to the bottom of the column."none"
or "zero"
will treat the text as if it has a value of zero.Upgrading from the original tablesorter to this fork "should be" fairly transparent, there are lots of new options, some modifications to options (e.g. dateFormat
); and only widgetZebra
was completely replaced. Hopefully the documentation is extensive enough to make it less painful.
Upvotes: 1