ignore sorting on a particular column tablesorter

时光毁灭记忆、已成空白 提交于 2019-12-12 10:44:20

问题


Can I ignore sorting on a particular column in jquery tablesorting plugin?

So basically when the page is loaded I do not not want any sorting done on the column "Search" because it contains images and does some javascript processing of its own and this slows down my sorting considerably.

Here is my code:

<script type="text/javascript">
jQuery(document).ready(function() { 

    jQuery("table").tablesorter({ 


}); 

});

    puts "<table cellspacing=\"1px\" class=\"tablesorter\" >"
    puts "<thead>"
    puts "<tr>"
    puts    "<th>Search</th>"
    puts    "<th>Sub-App</th>"
    puts    "<th>Division</th>"
    puts    "<th>Region</th>"
    puts    "<th>Market</th>"
    puts    "<th>Language</th>"
    puts    "<th>Function</th>"
    puts    "<th>LOB</th>"
    puts    "<th>Term</th>"
    puts    "<th>Center</th>"
    puts "</tr>"
    puts "</thead>"
    puts "<tbody>"

    puts "<tr>"
    puts    "<td id=\"$cellID\">"
    puts    "<img src=\"images/magnifier.gif\" style=\"cursor:pointer\" onclick=\"showRouting({'spec':'${specific}', 'id':'${mkt_id}', 'name':'${mkt_name}', 'xfer':'${xfertype}', 'cell':'${cellID}'})\"</img>"
    puts    "</td>"
    puts    "<td>$level</td>"
    puts    "<td>$div_name</td>"
    puts    "<td>$reg_name</td>"
    puts    "<td>$link</td>"
    puts    "<td>$lang</td>"
    puts    "<td>$func</td>"
    puts    "<td>$lob</td>"
    puts    "<td>$term</td>"
    puts    "<td>$ctr_name</td>"
    puts "</tr>"

    puts "</tbody>"
    puts "</table>"

回答1:


As per the documentation, you can now use class="sorter-false"




回答2:


Never mind. the following answers my question. it doesnt sort any faster because it still displays the images on that column.

 headers: {
            0: { sorter: false }

        }



回答3:


Add a noSort class to the </td> header of the columns you don't want sorted and then to the following:

$(document).ready(function() { 

    // Get Headers with Class noSort //
    var theHeaders = {}
    $(this).find('th.noSort').each(function(i,el){
        theHeaders[$(this).index()] = { sorter: false };
    });

    // Initialize Table Sorter //
    $("table").tablesorter({
         headers: theHeaders
    });
}); 

I hope this helps!



来源:https://stackoverflow.com/questions/10857742/ignore-sorting-on-a-particular-column-tablesorter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!