如何在tablesorter中忽略具有特定类名的? [英] How to ignore th with specific class name in tablesorter?
本文介绍了如何在tablesorter中忽略具有特定类名的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用tablesorter对表进行排序,但不是所有列,我想忽略具有已定义类名的特定列,例如:
I use the tablesorter to sort the table, but not all columns, I want to ignore the specific column with the defined class name, eg:
<table class="basicList" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="ck_field"><input type="checkbox" id="check_all" name="check_all" /></th>
<th class="col_filter"><a href="#" class="btn_filter"> </a></th>
<th>Name <span class="sort_indicator"> </span></th>
</tr>
<tr class="filter_row">
<td> </td>
<td> </td>
<td> <input type="text" id="the_name" name="name" class="filter_field"/></td>
</tr>
</thead>
</table>
在这个例子中,我不想对前两列进行排序。
In this example, I don't want to sort the first two columns.
我试过:
$(document).ready(function() {
console.log($(".basicList .col_filter").index());
console.log($(".basicList .ck_field").index());
var ck_ignore = $(".basicList .ck_field").index();
var filter_ignore = $(".basicList .col_filter").index();
$(".basicList").tablesorter({ widgets: ['zebra'],headers: {
//disable the first checkbox cell
$ck_ignore: {
sorter: false
},
$filter_ignore : {
sorter: false
}
}
});
哪个不行,怎么解决这个问题?
Which doesn't work, how to solve this problem?
推荐答案
像这样使用它:
var myHeaders = {};
myHeaders[ck_ignore] = { sorter: false };
myHeaders[filter_ignore] = { sorter: false };
$(".basicList").tablesorter({ widgets: ['zebra'], headers: myHeaders });
注意:如果您有更多列与这些类,它将只适用于第一次出现。
Note: if you have more columns with these classes, it will work only for the first occurences.
这篇关于如何在tablesorter中忽略具有特定类名的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文