Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- headers: { 0: {sorter: false}, 1: {sorter: false} }
- $("#nameCol").click(function() {
- var sorting = [[2, 0]]; /* sort 3rd col (Category) descending */
- $("#SearchResults").trigger("sorton", [sorting] ); /* SearchResults is the ID of the sortable table */
- return false; /* cancel default link action on a#nameCol */
- });
- $('th').click(function() {
- handleHeaderClick(this);
- });
- function handleHeaderClick(hdr) {
- if ($(hdr).hasClass('headerSortDown') == true) {
- $(hdr).removeClass('headerSortDown');
- $(hdr).addClass('headerSortUp');
- } else if ($(hdr).hasClass('headerSortUp') == true) {
- $(hdr).removeClass('headerSortUp');
- $(hdr).addClass('headerSortDown');
- } else {
- $('th', myTable).removeClass('headerSortUp headerSortDown');
- $(hdr).addClass('headerSortDown');
- }
- doSomething();
- };
- function SaveSortOrder(tablename) {
- //returns an array of a tablesorter sort order
- var hdrorder = new Array();
- var hdrs = $("#" + tablename + " th");
- var arrayindex = 0;
- hdrs.each(function (index) {
- if ($(this).hasClass('headerSortDown')) {
- hdrorder[arrayindex] = [index, 0];
- arrayindex++;
- }
- else if ($(this).hasClass('headerSortUp')) {
- hdrorder[arrayindex] = [index, 1];
- arrayindex++;
- }
- });
- return hdrorder;
- }
- $("#yourtableId").on("sortEnd", function(event) {
- // prints the current sort order to the console
- console.log(event.target.config.sortList);
- });
- lastSortList=$("#mytable")[0].config.sortList;
- $("#mytable").trigger("sorton", [lastSortList]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement