Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~

Home Page:https://mottie.github.io/tablesorter/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-columns-sorting works only after the first manual sorting

automatix opened this issue · comments

Hello!

Following scenario: I have a table with columns A, B, C, and D. All the columns excepting the C are sortable. The Default sorting is: D [DESC], A [ASC] . Working fine. But now I want to add a further column (D) to the sorting (SCHIFT + click on the column's head).

Expected behavior: The primary and the secondary sorting remain as they are. A tertiary sorting (by D) is added. The table is sorted by three columns.

Observed behavior: The primary and the secondary sorting get reset. The table is now sorted only by the column D.

My code:

$(function () {
    $("#content .table").tablesorter({
        textExtraction: function (node, table, cellIndex) {
            n = $(node);
            return n.attr('data-normalized') || n.text();
        },
        headers: {
            2: {
                sorter: false
            }
        },
        cancelSelection: true,
        sortList: [
            [3,1], [0,0]
        ],
        widgets : ['columns'],
        widgetOptions : {
            columns : ['primary', 'secondary', 'tertiary'],
            columns_thead : true,
            columns_tfoot : true
        }
    });
});

For me it seems to be a bug, but maybe it's just about configuration?..

Best regards,
Ilya

Hi @automatix!

Thanks that looks like a bug! I found a work-around until I get some time to fix the code base. Add the following code (demo):

initialized: function(table) {
  table.config.last.sortList = table.config.sortList;
}

Thank you very much!

Fixed in the master branch... I'll include it in the next update.