javascript - 在 jQuery DataTables 1.9 中,如何按 colspanned header 排序?

标签 javascript jquery sorting 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 按跨栏标题进行排序?

最佳答案

不幸的是,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/

相关文章:

javascript - AJAX 数据返回和动态更改元素

javascript - 调用一个函数并向它传递一个 json 对象

algorithm - 合并排序中的递归、快速排序和树的遍历

java - 树形图到数组。数组是否保持顺序?

javascript - 数据模型未在 Controller 中反序列化

javascript - 选择器上的 Jquery 单击事件返回子作为目标

javascript - jQuery解构 | ES 5 术语中的 JQuery 对象?

javascript - 对特定 CSS 背景图像应用效果

javascript - 使用 mCustomScrollbar jquery 刷新后滚动到顶部如何防止它

java - Java中根据3个自定义字符串对ArrayList进行排序