【发布时间】:2014-10-29 19:10:23
【问题描述】:
我正在将 datatables 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 按跨栏标题排序?
【问题讨论】:
标签: javascript jquery sorting datatables