如何在jQuery表分类器中的多个头中禁用一个头

时间:2014-08-26 17:19:45

标签: jquery css tablesorter

我使用过this table sorter plugin。现在,我要在<thead>中使用多个标头。我只希望一行保持活动状态以进行排序。没有该行,我希望禁用其他行标题进行排序。我该怎么做? Here is my fiddle是否有任何方法可以通过css类禁用一个标头?

<thead> 
<tr> 
    <th class="sorter-false">Info</th> 
    <th class="sorter-false">Info</th> 
    <th class="sorter-false">Info</th> 
    <th class="sorter-false" colspan="2">Text</th> 
</tr> 
<tr> 
    <th>Last Name</th> 
    <th>First Name</th> 
    <th>Email</th> 
    <th>Due</th> 
    <th>Web Site</th> 
</tr> 
</thead>

2 个答案:

答案 0 :(得分:2)

您可以在表格分类器插件中添加参数:

 $("#myTable").tablesorter({
    theme: 'blue',
    selectorHeaders: '.sorter-true'
});

小提琴示例:http://jsfiddle.net/lparcerisa/dcwrh9Lx/1/

答案 1 :(得分:1)

From their documentation:

  

...禁用表格前两列的排序:   headers: { 0: { sorter: false}, 1: {sorter: false} }

你还有一些行似乎把它搞砸了......我在这里更新了你的小提琴,例如排除前两个排序:http://jsfiddle.net/8cx76gu9/1/

将0和1更改为您想要更改的列的任何索引