9

我正在使用tablesorter jquery 插件,我的表在标题中有两行。有什么办法可以在我的桌子上进行排序?它应该能够按第二个标题行排序,第一个标题行就在那里按日期对相关数据进行分组。如果使用此插件无法做到这一点,也许有人有解决方法的建议?

这是我的表格标记的示例

<table>
  <thead>
    <tr>
      <th colspan="3">January</th>
      <th colspan="3">February</th>
      <th colspan="3">March</th>
    </tr>
    <tr>
      <!-- January -->
      <th>Metric 1</th>
      <th>Metric 2</th>
      <th>Metric 3</th>
      <!-- February -->
      <th>Metric 1</th>
      <th>Metric 2</th>
      <th>Metric 3</th>
      <!-- March -->
      <th>Metric 1</th>
      <th>Metric 2</th>
      <th>Metric 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <!-- January -->
      <td>Value 1</td>
      <td>Value 2</td>
      <td>Value 3</td>
      <!-- February -->
      <td>Value 1</td>
      <td>Value 2</td>
      <td>Value 3</td>
      <!-- March -->
      <td>Value 1</td>
      <td>Value 2</td>
      <td>Value 3</td>
    </tr>
    <tr>...</tr>
    <tr>...</tr>
    <!-- etc -->
  </tbody>
<table>
4

1 回答 1

16

您所要做的就是尝试;)

http://jsfiddle.net/Mottie/4mVfu/402/

如果您希望禁用顶行,则sorter-false向这些标题单元格添加一个类:

<tr>
  <th class="sorter-false" colspan="3">January</th>
  <th class="sorter-false" colspan="3">February</th>
  <th class="sorter-false" colspan="3">March</th>
</tr>

http://jsfiddle.net/Mottie/4mVfu/403/

于 2013-05-30T03:50:24.570 回答