Multitable sorting with single click

Multitable sorting with single click

soullightersoullighter Posts: 1Questions: 0Answers: 0
edited October 2015 in Free community support

Hello all,

I need to sort multiple tables with single click on <th> of first table. So i found this code but its not good for me because i need to sort asc and desc, and not just asc like it is now.

Here is the code

$(document).on("click", ".myTable thead th", function () {
             var index = $(this).closest("thead").children("tr").find("th").index($(this));

             var allTables = $.fn.dataTable.fnTables();

             for (var i = 0; i < allTables.length; i++) {
                 $(allTables[i]).dataTable().fnSort([[index, "asc"]]);
             }
        })
This discussion has been closed.