我将数据表 1.9 应用于这种形式的表:
<table>
<thead>
<tr>
<th rowspan=2>Player</th>
<th colspan=2>Overall</th>
<th colspan=2>Technique</th>
<th colspan=2>Style</th>
</tr><tr>
<th>Rank</th><th>Score</th> <!-- for overall -->
<th>Rank</th><th>Score</th> <!-- for technique -->
<th>Rank</th><th>Score</th> <!-- for style -->
</tr>
</thead><tbody>
<tr>
<td>Player 2</td><td>1</td><td>93</td><td>2</td><td>87</td><td>1</td><td>99</td>
<tr></tr>
<td>Player 3</td><td>2</td><td>89</td><td>1</td><td>94</td><td>3</td><td>86</td>
<tr></tr>
<td>Player 1</td><td>3</td><td>87</td><td>3</td><td>85</td><td>2</td><td>89</td>
</tr>
</tbody>
</table>
这样看可能更容易理解:
┌──────────┬──────────────┬──────────────┬──────────────┐
│ │ Overall │ Technique │ Style │
│ Player ├──────┬───────┼──────┬───────┼──────┬───────┤
│ │ Rank │ Score │ Rank │ Score │ Rank │ Score │
├──────────┼──────┼───────┼──────┼───────┼──────┼───────┤
│ Player 2 │ 1 │ 93 │ 2 │ 87 │ 1 │ 99 │
├──────────┼──────┼───────┼──────┼───────┼──────┼───────┤
│ Player 3 │ 2 │ 89 │ 1 │ 94 │ 3 │ 86 │
├──────────┼──────┼───────┼──────┼───────┼──────┼───────┤
│ Player 1 │ 3 │ 87 │ 3 │ 85 │ 2 │ 89 │
└──────────┴──────┴───────┴──────┴───────┴──────┴───────┘
由于每个类别中的每个排名恰好对应于同一类别中的一个分数,因此我想按类别(标题的顶行)而不是各个列(标题的底行)对该表进行排序。
如何使用 dataTables 1.9 按跨栏标题进行排序?
最佳答案
不幸的是,dataTables 不支持此功能。您可以在以下文档中找到最接近此功能的功能:
http://datatables.net/release-datatables/examples/advanced_init/row_grouping.html
关于javascript - 在 jQuery DataTables 1.9 中,如何按 colspanned header 排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26638659/