Code Monkey home page Code Monkey logo

tablesorter's Introduction

tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell. This forked version adds lots of new enhancements including: alphanumeric sorting, pager callback functons, multiple widgets providing column styling, ui theme application, sticky headers, column filters and resizer, as well as extended documentation with a lot more demos.

NPM Version devDependency Status zenhub-image

Notice!

  • Because of the change to the internal cache, the tablesorter v2.16+ core, filter widget and pager (both plugin & widget) will only work with the same version or newer files.

Questions?

irc-image slack-image stackoverflow-image

  • Check the FAQ page.
  • Search the main documentation (click the menu button in the upper left corner).
  • Search the issues to see if the question or problem has been brought up before, and hopefully resolved.
  • If someone is available, ask your question in the #tablesorter IRC channel at freenode.net.
  • Ask your question at Stackoverflow using a tablesorter tag.
  • Please don't open a new issue unless it really is an issue with the plugin, or a feature request. Thanks!

Demos

Features

  • Multi-column alphanumeric sorting and filtering.
  • Multi-tbody sorting - see the options table on the main document page.
  • Supports Bootstrap v2-4.
  • Parsers for sorting text, alphanumeric text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats) & time. Add your own easily.
  • Inline editing - see demo.
  • Support for ROWSPAN and COLSPAN on TH elements.
  • Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria).
  • Extensibility via widget system.
  • Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+, Chrome 5.0+.
  • Small code size, starting at 25K minified.
  • Works with jQuery 1.2.6+ (jQuery 1.4.1+ needed with some widgets).
  • Works with jQuery 1.9+ ($.browser.msie was removed; needed in the original version).

Licensing

Download

Related Projects

Contributing

If you would like to contribute, please...

  1. Fork.
  2. Make changes in a branch & add unit tests.
  3. Run grunt test (if qunit fails, run it again - it's fickle).
  4. Create a pull request.

Special Thanks

  • Big shout-out to Nick Craver for getting rid of the eval() function that was previously needed for multi-column sorting.
  • Big thanks to thezoggy for helping with code, themes and providing valuable feedback.
  • Big thanks to ThsSin- for taking over for a while and also providing valuable feedback.
  • Thanks to prijutme4ty for numerous contributions!
  • Also extra thanks to christhomas and Lynesth for help with code.
  • And, of course thanks to everyone else that has contributed, and continues to contribute through pull requests and open issues to this forked project!

Recent Changes

View the complete change log here.

Version 2.31.3 (2020-03-03)

  • Core:
  • AlignChar:
  • Pager:
    • Restore first row in cacheIndex. Fixes issues #1714 & #1710.
  • Docs:
    • Update to jQuery 3.4.1 & migrate 3.1.0.
    • Update to Bootstrap 4.4.1.
    • CSS cleanup - code font size was off.

Version 2.31.2 (2019-12-01)

Version 2.31.1 (2018-11-20)

  • Core:
  • Math:
  • Readme:
    • Remove bower, gitter & add Slack.
  • Meta:
    • Update dependencies.

tablesorter's People

Contributors

aavmurphy avatar adamz01h avatar babaevmm avatar camallen avatar ced-b avatar christhomas avatar craga89 avatar dandv avatar eire1130 avatar frennetix avatar herst avatar johnjameswhitman avatar jzturrini avatar larsbonczek avatar lbodtke avatar lvlynx avatar maksimprogr avatar medumont avatar mottie avatar mwiencek avatar omgimalexis avatar rozwell avatar simenflatby avatar stephenzeng55 avatar themilkman avatar thesin- avatar tim-schilling avatar victort83 avatar vividboarder avatar vorontsovie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tablesorter's Issues

removeRows: false causes some rows to be hidden

Hi,

I have been using your tablesorter plugin for a while now and it is great. I am also enjoying some of the updates you have recently done.

On one of my tables I have added the pager plugin. When I have 10 rows or less, no problems. As sson as I go over 10 rows issue start to appear.

In my particualr example I have 24 rows in the table. The pager says it is displaying 1 to 10 of 24 rows, but I only see 5. If I select 20 rows as the number of rows to display, the pager says 1 to 20 of 24 rows, but I only see 10 rows.

If I look at the HTMl in Firebug, I can see the rows but they are set to hidden.

I have downloaded the latest version of both the sorter(28) and the pager(1/31/2012).

Please can you help me shed some light on what might be going wrong.

Allow for negative numbers in parentheses

Accountants like to see negative numbers wrapped in parentheses instead of using a minus sign. For negative currency amounts, the currency symbol is placed inside the parens.

Here's my patch that adds paren handling to formatFloat() and updates isDigit(), currency.is(), currency.format(), and percent.is() to allow/preserve them.

formatFloat: The regex of \([.\d]+\) might be a little restrictive, but currency and percent signs have already been stripped out, so these negative numbers shouldn't be any more complex than "(1234.56)". Replacing ( with - seemed simpler than adding a flag to flip the sign after parseFloat().

isDigit: I added the parens to the test regex so they're in the same group as +/-, instead of stripping them out in the replace.

currency/percent is(): Allow for optional parens before currency symbol or after percent sign.

currency.format(): Preserve parens so they get passed to formatFloat.

I think this covers all the numberic parsers without adding much complexity. I didn't make this a flag like usNumberFormat because that would overcomplicate the regexes, and these changes should handle both minus-sign and parentheses negatives interchangeably.

--- jquery.tablesorter.js   2012-04-16 14:58:22.615183200 -0400
+++ jquery.tablesorter.negativeparens.js    2012-04-16 15:02:12.971317400 -0400
@@ -768,13 +768,16 @@
                    // French Format = 1 234 567,89 -> 1234567.89
                    s = s.replace(/[\s|\.]/g,'').replace(/,/g,'.');
                }
+               if(/^\s*\([.\d]+\)/.test(s)) {
+                   s = s.replace(/^\s*\(/,'-').replace(/\)/,'');
+               }
                var i = parseFloat(s);
                // return the text instead of zero
                return isNaN(i) ? $.trim(s) : i;
            };
            this.isDigit = function(s) {
                // replace all unwanted chars and match.
-               return (/^[\-+]?\d*$/).test($.trim(s.replace(/[,.'\s]/g, '')));
+               return (/^[\-+(]?\d*[)]?$/).test($.trim(s.replace(/[,.'\s]/g, '')));
            };
            this.clearTableBody = function (table) {
                $(table.tBodies[0]).empty();
@@ -816,10 +819,10 @@
    ts.addParser({
        id: "currency",
        is: function(s){
-           return (/^[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s); // £$€¤¥¢?.
+           return (/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]/).test(s); // £$€¤¥¢?.
        },
        format: function(s){
-           return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9,. \-]/g), ""));
+           return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9,. \-()]/g), ""));
        },
        type: "numeric"
    });
@@ -871,7 +874,7 @@
    ts.addParser({
        id: "percent",
        is: function(s) {
-           return (/\%$/).test($.trim(s));
+           return (/\%\)?$/).test($.trim(s));
        },
        format: function(s) {
            return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g), ""));

Sort empty cells to top

Planning to add an option to choose to sort empty cells to either the top or the bottom (default value).

Filter Plugin - Not specific enough find

Mottie! I have one little tweak/fix that was making something conflict for me.

In the filter plugin, around line 122 there is this:

v = tbl.find('.filter').map(function(){ return ($(this).val() || '').toLowerCase(); }).get();

That was conflicting with an icon that had class "filter" for me in my header, causing all the filters to be off by 1.
A more specific find helped with the issue:

v = tbl.find('thead tr.filters .filter').map(function(){ return ($(this).val() || '').toLowerCase(); }).get();

Thanks for the great work,
-Seth

zebra stripe result showing up twice in debug

I upgraded some existing code to use your much newer tablesorter, turned on debug to compare old vs new js. I threw away some old custom parser code to take advantage of using textExtraction / newer parsers. However everything else basically stayed the same. I even tried deleting all the parsers/textExtraction segment but still get the double zebra stripe being reported. Also I noticed that the newer tablesorter is reporting slower in several sections.. just curious if there were places I could optimize. Also, any plans to build in the cookie widget ( http://pastebin.com/raw.php?i=AJEtm48t ) ?

-- jquery.tablesorter-2.0.25.2.min.js:
Built headers:,6ms
jQuery(th.nowrap, th.header, th.header, th.header, th.header, th.header, th.header)
Checking if value was empty on row:0
Checking if value was empty on row:0
Checking if value was empty on row:0
column:0 parser:isoDate column:1 parser:loadingNames column:2 parser:text column:3 parser:quality column:4 parser:eps column:5 parser:text column:6 parser:text
Building cache for 74 rows:,31ms
Sorting on 4,0 and dir 0 time:,155ms
Rebuilt table:,35ms
Applying Zebra widget,37ms
Applying Zebra widget,376ms

-- jquery.tablesorter-2.0.3.min.js:
Built headers:,1ms
jQuery(th.nowrap, th.header, th.header, th.header, th.header, th.header, th.header)
column:0 parser:nextAirDate column:1 parser:loadingNames column:2 parser:text column:3 parser:quality column:4 parser:eps column:5 parser:active column:6 parser:text
Building cache for 74 rows:,17ms
Sorting on 4,0 and dir 0 time:,1ms
Rebuilt table:,28ms
Applying Zebra widget,67ms

empty cells handling.

I found that the original table sorter seemed to be meant to be able to force empty cells to tjhe bottom (on both asc and desc sorts) but was slightly miscoded.

I fixed it in my version by:

In the parsers, checking for empty cells and if so passing returning an empty value, otherwise continue with parser code.

In makeSortFunction() change the nulls to '' (empty string)

Can you incorporate this into your version?

Table Filter

I had a request to add a table filter/search. I may just make a quick widget, but it wouldn't work very well along side of the pager plugin. So, I'm opening this ticket to remind me to make a better version.

Stay tuned for the widget though.

error: Maximum call stack size exceeded

Hi, I'm sorry for my bad English ...
When I do an update of the table I get the following error: 'Maximum call stack size exceeded'

I use the code for the update to php is as follows:

 $ ("# Tables tbody"). Children ('tr'). Remove ();
 $ ('# tables tbody'). fadeIn ('slow'). append (msgs);
 $ ("# tables tbody"). trigger ("update");

And 'as the correct syntax?

Error: Uncaught TypeError: undefined is not a function

I ran into an error when js files are combined:

Uncaught TypeError: undefined is not a function

(function($){

})(jQuery);

But if I use the Twitter Bootstrap method I didn't have any errors:

! function($){

}(window.jQuery)

Print Stylesheet Paging Help

Hey Mottie, me again. I have a quick recommendation/comment about an issue I ran into with print stylesheets. When using the pager plugin, it sets hidden rows to display:none, which is all well and fine. Works well, but when I go to print the table, I can't easily show them with a print stylesheet.

My fix idea: Instead of using display:none, use a namespaced class like you have been doing tablesorter-pager-hidden or something like that. The filter behaves the same way, but I don't really see the need to print filtered content, but maybe someone comes up with an idea to need to show those with css (or maybe make them less opaque?) so then namespace that too.

Check out: addons/pager/jquery.tablesorter.pager.js:63
The filter widget looks like it might use show() and hide() in a couple places in that widgets file.

I know the table and the filter aren't really supposed to work together, but they do work really well together! There are a few anomalies, but nothing too bad. If this method is implemented it may be even easier for it to work, not sure. I haven't dove in that far yet.

Thanks for all your help, as always,
-Seth

changelog

uhh looks like anyone can go delete/edit your changelog. i just successfully deleted it... but i put it back.

Numeric sort with emptyToBottom=null treats empty as zero

For text fields, emptyToBottom=null works as described, sorting empty cells before "a", so as you toggle the sort direction, the empty cells bounce between the top and bottom of the table.
With numeric sorts, emptyToBottom=true/false works as expected, grouping empty cells at either the top or bottom of the table, and keeping them there regardless of the sort direction.
But numeric sorting with emptyToBottom=null treats empty cells as zero, grouping empties and zeroes between the positive and negative numbers.

Example:
Add these rows to the bottom of the table in example-option-sort-empty.html

        <tr>
            <td>A109</td>
            <td>Larry</td>
            <td>Stevens</td>
            <td>56</td>
            <td>153.19</td>
            <td>23%</td>
            <td>0</td>
        </tr>
        <tr>
            <td>A99</td>
            <td>John</td>
            <td>Smithy</td>
            <td>56</td>
            <td>156</td>
            <td>22%</td>
            <td></td>
        </tr>

Sorting on the "diff" column with emptyToBottom=null will sort empty, zero, empty (preserving their initial order) to the middle of the list between the positives and negatives.

To get emptyToBottom=null to behave as described ("as if the cell has the lowest value") for numeric sorts, I added these lines to sortNumeric:

    if (a === '' && c.emptyToBottom === null) { return -1; }
    if (b === '' && c.emptyToBottom === null) { return 1; }

and the opposite to sortNumericDesc:

    if (a === '' && c.emptyToBottom === null) { return 1; }
    if (b === '' && c.emptyToBottom === null) { return -1; }

The only problem I have with this is that it removes the ability to treat empty like zero, but I think that's too confusing to be useful.

Tablesorter + json data support

Hi,
i have this idea of implementing json data instead of table rows data. The server side returns directly json, table sorter uses it instead of building cache and parsing DOM. What do you think about that? Is it feasible to build such a thing? In this case we save lots of bulk data send from the server as <tr><td></td></tr>
The table headers will stay as they are now, and tablesorter can init on empty table.

BR,
Ilko

How to make more than 1 row sticky?

I want make more than 1 row of my table sticky.
If i put 3 TR in the THEAD with TH inside tablesorter just makes the last row sticky.
If i put 1 TR with TH and 2 TR with TD it makes only the 1 with TH sticky.
But how can I make all of my TR in THEAD sticky?

Add metadata support for numeric parser 'string' option

Thanks for your prompt responses to my issues so far. I've been trying to layer tablesorter on top of a large app that already has a table-builder component with lots of display and sorting options, so I'm currently full of "Does it handle this weird case? No? Can I make it?" ideas, and I'm trying to suggest only changes that would be useful to someone else outside of my particular app.

I don't know much about jQuery metadata, so I may be coming at this from the wrong direction, but I'd like to be able to set the string sort option in the table itself so I can have an ajax loader fire $("table.tablesorter", e).tablesorter({global options}) every time new content is loaded, rather than generating and running a .tablesorter() call for each table with table-specific options in it.

I want to do something like this:

    <th class="{sorter: 'digit', string: 'max+'}">5: Ratings (max+)</th>
    <th class="{sorter: 'digit', string: 'max-'}">6: Ratings (max-)</th>

I tried pulling the entire metadata hash and adding it to headers: {} (which sounds like a good idea and might eliminate the special metadata handling for sorter:), but I got a little confused inside the .each() in buildHeaders and couldn't decide whether headers or metadata should take precedence, so I went with the easy route and just changed multisort to look in metadata if the string option wasn't specified in headers: {}

function multisort ...

    // get max column value (ignore sign)
    if (/Numeric/.test(s)){
        var stringOpt;
        if(tc.headers[c] && tc.headers[c].string){
            stringOpt = tc.headers[c].string;
        } else if($.metadata && tc.headerList && tc.headerList[c] &&
                $(tc.headerList[c]).metadata() && $(tc.headerList[c]).metadata().string){
            stringOpt = $(tc.headerList[c]).metadata().string;
        }
        if(stringOpt){
            for (j=0; j < lc; j++) {
                col = Math.abs(parseFloat(cache.normalized[j][c]));
                mx = Math.max( mx, isNaN(col) ? 0 : col );
            }
            dir = stringOpt ? tc.string[stringOpt] || 0 : 0;
        }
    }

I'm sure I could generate individual per-table .tablesorter() calls in my app, or I could just keep my own local patches to tablesorter if you don't think this would be a useful addition.

Aside: Now I'm thinking about emptyToBottom as an enumeration like top,bottom,max,min,zero (no +/- so they could also be specified as a class name), but then a numeric column with both text and empty cells would add even more complexity to multisort(), and at that point, I should probably just calculate sort orders on the server and use the metadata sorter.

Sorter False does not work with uitheme Widget

I believe that we should adjust the tablesorter.widgets.js file to check for a disabled header by doing:
this.sortDisabled

For example:

        $.each(c.headerList, function(i){
            if (this.sortDisabled === true) {
                // no sort arrows for disabled columns!
                $(this).find('span.ui-widget-header').remove('.ui-icon');

sorter: isoDate

I have a table of data, with the first column being in the YYYY-MM-DD format. There are some rows where this field is empty.. so when sorting it will stick the newest date on top or sorting the other direction it puts the empty stuff on top. Is there a way to basically keep the rows with the empty columns at the bottom (didnt it used to do this?). Honestly this shouldnt be limited to isoDate but could be useful else where as well.. so maybe add a 'ignoreNull: true' option?

i can create a jsfiddle if you need some test data. hit me up on irc if you need to talk more

RemoveRows Error

Removerows set to false breaks addRows and Sorting.

workaround :

  • remove config.appender = null; on line 205 in tablesorter.pager.js
    *addRows needs to be called after manually appending the row to tbody.

Couldn't find a way to get sorting working.

wrong number of filter inputs

I have jquery ui tabs loaded via ajax. Each tab has tables with unique ID and tablesorter on them (with zebra and filter widgets).
When I click tabs one by one, tablesorter adds wrong number of filter inputs to tables:

(1st ut tab)
table with 2 columns

(2nd ut tab)
table with 3 columns

(3rd ut tab)
table with 2 columns - there i have 3 filter inputs


i think this bug in tablesorter becouse filter gets number of columns from it (that have not been updated from last tab)
my solution was changing line

cols = c.headerList.length,
to
cols = $("thead th", table).length,

in filter widget. It works but i dont think that good way to fix this. Check please)

sortInitialOrder reset

Hi. Nice tool. One thing that might be helpful would be to enable the ability to reset sortInitialOrder for a column if a different column is selected for sorting. In other words, if I select column 0 (which sorts by its sortInitialOrder) then I select column 1 (which sorts by its sortInitialOrder) but then I select column 0 again, it will sort by !sortInitialOrder. This does not feel natural when moving between columns, imho. I believe in order to achieve this the default sort state would need to be 'reset' for any column that is 'selected away from' (or brute-forcely, all columns that are not selected). I guess ideally it would be possible to have a property to allow the coder to specify whether s/he wants that column's sortInitialOrder reset when selecting other columns. thoughts?

stickheaders - offset/margin

noticed that with the latest stickyheaders.. you are specifying the width then trying to offset the border.. so what we end up is something that is slightly larger than before and -1px to the left.. which is just really off. if i do -2px margin-left and turn off your width statement things look good. its a box sizing issue between using a fixed width and a border.. which is a no no.

in css you can do this (latest gen browsers):
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;

anyways hit me up on irc, i probably can come up with a jsfiddle for you to test with. also some ss. i'd do it now.. but i'm at work currently

Minify - build script

I noticed that when you make your .min versions.. you insert a line break after the comment.. can this be removed? (cosmetic)
Also, you should update your comment to do /*! so that it doesn't get removed if someone runs it through their build script to minify code.

Combination Sticky header widget+Filter widget

Hello :)

I like to combine sticky header and filter widget and i have noticed the following issue:

$("#myTable").tablesorter({ widgets: ['zebra', 'filter', 'stickyHeaders'] });

First, if 'filter' is before 'stickyHeaders', then you will have the filter-row as sticky header...

This solution works fine for me: widgets: ['zebra', 'stickyHeaders', 'filter']

only one exception:
I have noticed, if I open a website, where such a table is displayed and i scroll down at browser, so that stickyHeaders appear, then the width size of the stickyHeaders is not correct related to column sizes.
I could solved this issue easily by changing the width of the browser, then stickyHeaders width size fits like it should be.

greetings
Nils

filter widget ignores child rows

When you have child rows marked with expand-child, tablesorter doesn't keep them together with the parent, so if you have a second match it replaces the child of the first row. For example:

first column, first row second column first row
first child row
first column, second row second column, second row
second child row

with this you can see that if you filter it you'll see the second row in place of the first child.

Different effect for setting sorter false for a column

Hello :)

I noticed a different effect for setting sorter false for a column by two different methods:
(I inserted '.' inside HTML code to display tags here)

Method 1 to disable sorter for column 0:

    $("#myTable").tablesorter(
    {
        widgets : ['uitheme', 'zebra', 'stickyHeaders', 'filter'],
        widgetZebra: { css: ["ui-widget-content", "ui-state-default"] },
        widgetUitheme: { css: ["ui-icon-carat-2-n-s", "ui-icon-carat-1-s", "ui-icon-carat-1-n"] },

        headers:
        {
          0:
          {
                    sorter: false 
          }
        }
    });

This works fine!
Generated table header code is:

<.th class="ui-widget-header ui-corner-all">
<.span><./span>
<.span class=""><./span>
<./th>

Methode 2 to disable sorter for column 0:
-Disable (or set) the column parser using class names
<.th class="sorter-false"><./th>

so you only need this now without an addional headers-option:

    $("#myTable").tablesorter(
    {
        widgets : ['uitheme', 'zebra', 'stickyHeaders', 'filter'],
        widgetZebra: { css: ["ui-widget-content", "ui-state-default"] },
        widgetUitheme: { css: ["ui-icon-carat-2-n-s", "ui-icon-carat-1-s", "ui-icon-carat-1-n"] }
    });

This works almost fine, BUT the look is wrong!
Generated table header code is:

<.th class="sorter-false ui-widget-header ui-corner-all ui-state-active">
<.span><./span>
<.span class="ui-icon"><./span>
<./th>

The sorting for this column is disabled, but ui-state-active is activated and ui-icon is displayed. Both should not be.

I hope you had nice Christmas days and i wish a Happy New Year!
greetings

cosmetic/jshint - widget

was updating some code and was looking at your localStorage code for reference and noticed that inside:

$.tablesorter.storage = function(table, key, val){

missing space before =

v[url][id]= {};

Dynamic SortAppend

I have a request to make a dynamic sortAppend. Here is the request:

I've got 3 column table(status, date, doc type), clicking on status should sort status & date, clicking on date should sort date & doc type, clicking on doc type should sort doc type & date.

So basically there is a default sortAppend option on the date column, but when the date colum is sorted first, add a different secondary sort.

The sortStart event doesn't work in this case because the sortList isn't defined at that point. The sortEnd event won't work, because, well the sort is already done.

Skip span within column when sorting

Hi, I hope this is the appropriate place to post this question. I have Tablesorter up and working great but I wonder if it is possible to ask the sorter to skip a class within a column (I am a newbie with javascript so please forgive me in advance). I have a column in a dynamically generated table that is sorted first, the markup can look something like

<td class="plantname">
  <span class="crossgenus">χ</span>
  <span class="genus">Fatshedera</span>
  <span class="species">lizei</span>
  <span class="cultivar">'Annemeike'</span>
</td>

It seldom occurs that the "crossgenus" span shows up with content, but when it does the content is always the χ symbol, and this naturally gets sorted to the very bottom of the table, under Z. Where I want the plant listing to show up is under 'Fatshedera' (the genus), ignoring the span "crossgenus". I looked at the textExtraction function but don't know enough to figure out if/how it could be applied to this case. Any help would be greatly appreciated. Thank you!

Clicking on a column to sort reverts to previous numbers of rows displayed

problem with demo.

http://mottie.github.com/tablesorter/docs/example-pager.html

(the bug) If you Refresh/load the page,(it will default to 10 records) then select 20 (it will now display 20 records). Now click on any column to sort these 20 record, it WILL sort BUT will go back to displaying 10 Records

(observation) this time select 20 record, and F5 to REFRESH the Page. Now click on any column to sort these 20 record, it WILL CORRECTLY

Filter and pager

Hi!
Filter widget and pager plugin don't work together.
Any ideas?

Header name and desc/asc symbols overlaps

Hello :)

I have noticed the following issue, if you reduce much the width of the browser, then header name and desc/asc symbols will overlap. In my opinion this doesn't look nice.

Picture example for blue skin:
http://s7.directupload.net/file/d/2732/niutsquo_jpg.htm

Picture example for cupertino UI theme style:
http://s14.directupload.net/file/d/2732/85bunm8q_jpg.htm

One possible solution for the blue skin would be this:

Add at style.css of the Blue Skin:

table.tablesorter thead tr th, tr.stickyHeader th, table.tablesorter tfoot tr th 
{
    background-color: #e6eeee;
    border-collapse: collapse;
    font-size: 8pt;
    padding: 4px;
    padding-right: 20px;  /* NEW LINE */
}

Unfortunately this solution doesn't seem to work for Cupertino UI theme style.
I added same new line to style.css like the css code at http://mottie.github.com/tablesorter/docs/example-widget-ui-theme.html

table.tablesorter thead tr th, table.tablesorter tfoot tr th 
{
    border-collapse: collapse;
    font-size: 8pt;
    padding: 4px;
    padding-right: 20px; /* NEW LINE */
}

But no effect...

cookie widget

//http://web.archive.org/web/20080801073104/http://www.jdempster.com/category/code/jquery/tablesortercookiewidget/
$.tablesorter.addWidget({
  id: 'cookie',
  format: function(table) {
    var sortList = table.config.sortList;
    var tablesorterCookieJar = $.cookieJar('tablesorter');
    if ( sortList.length > 0) {
      tablesorterCookieJar.set($(table).attr('id'), sortList);
    } else {
      var sortList = tablesorterCookieJar.get($(table).attr('id'));
      if (sortList && sortList.length > 0) {
        jQuery(table).trigger('sorton', [sortList]);
      }
    }
  }
});

$(document).ready(function(){

  // workaround: the tablesorter cookie widget does not support a defaulted sortList set within the $.tablesorter() instantiation
  var tablesorterCookieJar = $.cookieJar('tablesorter');
  var sortList = tablesorterCookieJar.get('showListTable');
  if (!sortList || !sortList.length)
  sortList = [[5,1],[1,0]];

  $("#showListTable").tablesorter({
    sortList: sortList
  });

});

multi column sorting - chrome

http://oi44.tinypic.com/15y9rhx.jpg

chrome: 18.0.1025.142
if you try that same sort in any other browser.. it works as expected...

here is a demo: http://jsfiddle.net/VW4HX/8/embedded/result/

to see the chrome bug, load that demo as it is.. in both chrome and safari/ie/firefox. notice the null isoDate values are not sorted in chrome like they are in the other browsers.

besides the chrome thing.. i also found a quirk. if you look at how its initially being sorted.. scroll down to the null isoDate entries.. notice that its sorting in the opposite direction for the show names than whats being shown in the header. if you hold shift and click on the show name column once.. it fixes this. and note that the image doesnt change.

Change filter to display:none on columns with filter:false

Could you change the style on the columns with filter: false to display:none instead of visibility:none. That way it doesn't make the column's wider than they need to be.

Basically: line 110

            fr += ((c.headers[i] && 'filter' in c.headers[i] && c.headers[i].filter === false) || $(c.headerList[i]).is('.filter-false') ) ? 'display:none' : '';

Unexpected sorting

Hello :)

I observed an unexpected sorting of my table columns. Surely the sort parser cannot handle the column with my data.

Example:
First sorted table by "model" (i clicked header two times)
http://s7.directupload.net/file/d/2730/6gwhdybj_jpg.htm

Then i add sort table by "length" (i clicked header one time by holding shift-key)
http://s7.directupload.net/file/d/2730/l4docan9_jpg.htm

You will see that "model"-column lost any kind of sorting.

So I like to ask, if my special symbols like - and / at "model"-column are my problem or is it a parser-bug?

Do parser support sorting alpha-numeric columns with special symbols like - or / or _ or space charater?

Thanks for helping!
Greetings
Nils

emptyToBottom has no effect on date columns

The format() function of the date parsers convert empty cells to either zero or NaN. For emptyToBottom to work, these format() functions should return empty strings for empty cells instead of letting the Date() constructor or formatFloat() return NaN or zero, so sortNumeric() can catch the empty strings and use the emptyToBottom logic.

static StickyHeader by using jQuery UI theme

Hello :)

I use StickyHeader and jQuery UI theme together and noticed this issue:

I scroll down at browser, so sticky headers appear. These sticky headers are still clickable for asc/desc sorting, but the symbol for asc/desc sorting doesn't change.

greetings

Sticky header widget

Hello :)

Situation/Problem:
If you have a table with great width, then the browser displays a scollbar at bottom, where you can scroll left to right. The problem is that the sticky header doesnt scroll. For example, i scroll from left to right at browser, the first columns cannot be seen anymore, but the sticky header display the header for the first column still.

You can test it easy at example: http://mottie.github.com/tablesorter/docs/example-widget-sticky-header.html
First make window very small till browser display scrollbar at bottom, then test your sticky headers by scrolling to from left to right.

greetings
Nils

Widget: Filter - Use input type search

This is essentially a "search" action, so I think the HTML5 search box would be appropriate. Most browser widgets provide a little X to clear the search box too, clearing the filter area. Its a nice little touch.

I added this on my own, essentially all I did was change the input type to search, and made it listen to keyup and search events.

Just an idea, feel free to implement if you feel like it.

Thanks for the work on this, its a great table plugin,
-Seth

sortSave - initial sort / saved sort

looks like if you set sortList = whatever.. this is used if no savedSort exists (cookie/local storage). which works great.. however if you have an inital sort and use sortSave.. you see that per the debug it is set to one sorting..then set to another.

Built headers:,5ms
jQuery(th.nowrap, th.header, th.header, th.header, th.header, th.header, th.header)
Checking if value was empty on row:0
Checking if value was empty on row:0
Checking if value was empty on row:0
column:0 parser:isoDate column:1 parser:loadingNames column:2 parser:text column:3 parser:quality column:4 parser:eps column:5 parser:text column:6 parser:text
Building cache for 74 rows:,24ms
Sorting on 5,1,1,0 and dir 0 time:,6ms
Rebuilt table:,32ms
Applying Zebra widget,61ms
saveSort: Last sort for "tablesorter0showListTable" obtained from local storage,0ms
Sorting on 3,1,6,0,2,1,0,1 and dir 1 time:,5ms
Rebuilt table:,30ms
Applying Zebra widget,79ms
saveSort: Saving sort to "tablesorter0showListTable" in local storage,3ms

I would think that it should only do the initial sort if no saved is found.. as the zebra stripes happens twice..
also, is 'tablesorter0showListTable' suppose to look like that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.