Javascript 如何使用tablesorter分别对多组行进行排序?
我在tablesorter中看到过关于分组行的类似问题,但他们提出的问题与我想要的略有不同。我希望一个表有两组分别排序的行。例如:Javascript 如何使用tablesorter分别对多组行进行排序?,javascript,jquery,tablesorter,Javascript,Jquery,Tablesorter,我在tablesorter中看到过关于分组行的类似问题,但他们提出的问题与我想要的略有不同。我希望一个表有两组分别排序的行。例如: | col1 | col2 | col3 | <- this header never moves | A | 1 | 1.5 | | J | 3 | 2.7 | <- these three rows get sorted | X | 2 | 1.2 | |Totals| 6 | 5.4 |
| col1 | col2 | col3 | <- this header never moves
| A | 1 | 1.5 |
| J | 3 | 2.7 | <- these three rows get sorted
| X | 2 | 1.2 |
|Totals| 6 | 5.4 | <- This totals the first group and never moves
| another header row | <- this header never moves
| B | 5 | 5.0 |
| L | 3 | 8.2 | <- these three rows get sorted
| N | 7 | 3.3 |
|Totals| 15 | 16.5 | <- This totals the second group and never moves
| col1 | col2 | col3 |使用my,您可以添加多个tbodies,每个tbodies将与其他tbodies分开排序。对于总页眉和额外页眉,还要将它们添加到单独的tbody
元素中
<table class="tablesorter">
<thead>
<tr><th>col1</th><th>col2</th><th>col3</th></tr>
</thead>
<tbody><tr><!-- data --></tr></tbody>
<tbody><tr><th>Totals</th><!-- ... --></tr></tbody>
<tbody class="fake-header">
<tr><th>col1</th><th>col2</th><th>col3</th></tr>
</tbody>
<tbody><tr><!-- more data --></tr></tbody>
<tbody><tr><th>Totals</th><!-- ... --></tr></tbody>
</table>
我设置了一个包含math小部件的程序,可以自动为您计算行总数。所需的唯一更改位于“总计”行中:
<tbody>
<tr>
<th>Totals</th>
<th data-math="above-sum"></th>
<th data-math="above-sum"></th>
</tr>
</tbody>
我错过了假头球。但是数学的东西对我不起作用。看见还有,有没有一种方法不排序列?包括小部件代码()-。我还必须在标题周围添加另一个
。。。要停止对秩列的排序,请在
中添加一个sorter false
类。sorter false类意味着我不能使用该列进行排序,这很好,但我根本不希望对该列进行排序,也就是说,无论行如何排序,顶部列始终应为1,下一列为2,依此类推。
<tbody>
<tr>
<th>Totals</th>
<th data-math="above-sum"></th>
<th data-math="above-sum"></th>
</tr>
</tbody>
$(function() {
$('table').tablesorter({
theme: 'blue',
widgets: ['zebra', 'math'],
widgetOptions: {
math_mask: '#,###.#'
}
});
});