【发布时间】:2018-06-18 21:03:35
【问题描述】:
使用 TableSorter 插件,我需要对多个 TR 进行排序,这些 TR 是由多个 TR(未定义的子 TR 数量)组成的块(jsfiddle 中的示例)
<tbody id='ligne-pilote'>
<tr data-id='4578575' class='lineX'>
<td colspan='10' class='group-tr'>
<table class='line'>
<tr height='26'>
<td class='b-right' width='33%'>Arbre</td>
<td class='b-right' width='6%' align='center'><span>250</span></td>
<td class='b-right' width='6%' align='center'><span>360</span></td>
<td class='b-right' width='8%' align='center'>5</td>
<td class='b-right' width='8%' align='center'>35</td>
<td class='b-right' width='8%' align='center'>72</td>
<td class='b-right' width='8%' align='center'>1200</td>
<td class='b-right' width='6%' align='center'>3850</td>
<td class='b-right' width='15%' align='center'>2055</td>
<td class='' width='2%' align='center'>ok</td>
</tr>
<tr height='26' class='test'>
<td class='b-right b-top' width='33%'> - Pin blanc</td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col 2</span></td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col 3</span></td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 4</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 5</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 6</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 7</td>
<td class='b-right b-top' width='6%' align='center'>Sub-Data-col 8</td>
<td class='b-right b-top' width='15%'align='center'>Sub-Data-col 9</td>
<td class='b-top' width='2%' align='center'>ok</td>
</tr>
<tr height='26' class='test'>
<td class='b-right b-top' width='33%'> - Saules</td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col 2</span></td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col 3</span></td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 4</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 5</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 6</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col 7</td>
<td class='b-right b-top' width='6%' align='center'>Sub-Data-col 8</td>
<td class='b-right b-top' width='15%'align='center'>Sub-Data-col 9</td>
<td class='b-top' width='2%' align='center'>ok</td>
</tr>
</table>
</td>
</tr>
<tr data-id='45784515' class='lineX'>
<td colspan='10' class='group-tr'>
<table class='line'>
<tr height='26' >
<td class='b-right' width='33%'>Bateau</td>
<td class='b-right' width='6%' align='center'><span>3520</span></td>
<td class='b-right' width='6%' align='center'><span>6230</span></td>
<td class='b-right' width='8%' align='center'>321</td>
<td class='b-right' width='8%' align='center'>322</td>
<td class='b-right' width='8%' align='center'>323</td>
<td class='b-right' width='8%' align='center'>500</td>
<td class='b-right' width='6%' align='center'>780</td>
<td class='b-right' width='15%' align='center'>6542</td>
<td width='2%' align='center'>ok</td>
</tr>
<tr height='26' class='test'>
<td class='b-right b-top' width='33%'> - Royal Fortune</td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col2 2</span></td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col2 3</span></td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col2 4</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col2 5</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col2 6</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col2 7</td>
<td class='b-right b-top' width='6%' align='center'>Sub-Data-col2 8</td>
<td class='b-right b-top' width='15%' align='center'>Sub-Data-col2 9</td>
<td class='b-top' width='2%' align='center'>ok</td>
</tr>
<tr height='26' class='test'>
<td class='b-right b-top' width='33%'> - Royal James</td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col3 2</span></td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col3 3</span></td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 4</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 5</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 6</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 7</td>
<td class='b-right b-top' width='6%' align='center'>Sub-Data-col3 8</td>
<td class='b-right b-top' width='15%' align='center'>Sub-Data-col3 9</td>
<td class='b-top' width='2%' align='center'>ok</td>
</tr>
<tr height='26' class='test'>
<td class='b-right b-top' width='33%'> - The Ranger</td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col3 2</span></td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col3 3</span></td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 4</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 5</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 6</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 7</td>
<td class='b-right b-top' width='6%' align='center'>Sub-Data-col3 8</td>
<td class='b-right b-top' width='15%' align='center'>Sub-Data-col3 9</td>
<td class='b-top' width='2%' align='center'>ok</td>
</tr>
<tr height='26' class='test'>
<td class='b-right b-top' width='33%'> - Queen Anne's Revenge</td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col3 2</span></td>
<td class='b-right b-top' width='6%' align='center'><span>Sub-Data-col3 3</span></td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 4</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 5</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 6</td>
<td class='b-right b-top' width='8%' align='center'>Sub-Data-col3 7</td>
<td class='b-right b-top' width='6%' align='center'>Sub-Data-col3 8</td>
<td class='b-right b-top' width='15%' align='center'>Sub-Data-col3 9</td>
<td class='b-top' width='2%' align='center'>ok</td>
</tr>
</table>
</td>
</tr>
https://jsfiddle.net/gratien/mn3gpu2h/10/
当我点击“Col1”时,我只需要对该列的每个块的第一行进行排序,与“Col 2”相同,它必须只对第二列进行排序。
我不知道怎么做,你能帮忙吗?
谢谢!
【问题讨论】:
标签: javascript jquery html-table tablesorter