2012-06-01 66 views
5

我可以忽略jQuery的tablesorting插件特定的列進行排序排序?忽略特定列的tablesorter

當頁面加載所以基本上我不不想在列「搜索」做任何的排序,因爲它包含的圖像和做一些自己的JavaScript的處理,這會減慢我的大大排序。

這裏是我的代碼:

<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>" 

回答

7

沒關係。以下回答我的問題。它不會更快地排序,因爲它仍然在該列上顯示圖像。

headers: { 
      0: { sorter: false } 

     } 
6

添加noSort類列的</td>頭你不想排序,然後爲以下內容:

$(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 
    }); 
}); 

我希望這有助於!

10

按照該documentation,你現在可以使用class="sorter-false"

+0

,但要仔細,這只是因爲某些版本的支持,或許你有一箇舊,需要更新LIB – Tebe