2012-06-01 1 views
5

jquery tablesortingプラグインで特定の列のソートを無視できますか?特定の列テーブルーのソートを無視する

基本的にページが読み込まれるときに、画像が含まれていて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

をソートし、次にあなたがしたくない列の</td>ヘッダにnoSortクラスを追加します。

$(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

関連する問題