【问题标题】:ignore sorting on a particular column tablesorter忽略特定列 tablesorter 上的排序
【发布时间】:2012-06-07 03:14:52
【问题描述】:

我可以在 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>"

【问题讨论】:

    标签: jquery jquery-ui jquery-plugins tablesorter


    【解决方案1】:

    根据documentation,您现在可以使用class="sorter-false"

    【讨论】:

    • 但是要小心,它是从某个版本开始支持的,可能你有一个旧版本,需要更新 lib
    【解决方案2】:

    没关系。以下回答了我的问题。它没有更快地排序,因为它仍然在该列上显示图像。

     headers: {
                0: { sorter: false }
    
            }
    

    【讨论】:

      【解决方案3】:

      noSort 类添加到您不想排序的列的&lt;/td&gt; 标题,然后添加到以下内容:

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

      我希望这会有所帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-01
        • 2021-05-26
        • 2023-04-08
        • 1970-01-01
        • 2011-01-23
        相关资源
        最近更新 更多