对于每一行,我的下面都有一个穿过表格的colspan,这是该行的信息。我希望从tablesorter插件中排除信息行。这可能吗?
表格的结构如何。我需要将leg-info类从排序中排除。
<table>
<thead>
<tr>
<th class="header">expand</th>
<th class="header">Leg #</th>
<th class="header">Product</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#" class="leg-exp">expand</a></td>
<td>1</td>
<td>Revolver</td>
</tr>
<tr class="leg-info"><td colspan="3">
<div style="height: 90px; width:90px;">Info for row above</div>
</td>
</tr> <tr>
<td><a href="#" class="leg-exp">expand</a></td>
<td>1</td>
<td>Revolver</td>
</tr>
<tr class="leg-info"><td colspan="3">
<div style="height: 90px; width:90px;">Info for row above</div>
</td>
</tr> <tr>
<td><a href="#" class="leg-exp">expand</a></td>
<td>1</td>
<td>Revolver</td>
</tr>
<tr class="leg-info"><td colspan="3">
<div style="height: 90px; width:90px;">Info for row above</div>
</td>
</tr>
</tbody>
</table>
这是我试过的js
// init tablesorter and save reference to table
var $table = $('#myTable').tablesorter();
// save reference to dummy row
$dummyRow = $('#idDummy');
// save current index of dummyrow
savedIndex = $dummyRow.index();
// bind an event to the sortStart event of tablesorter
$table.bind('sortStart',function(){
// save current index of dummyrow
savedIndex = $dummyRow.index();
// detach dummyrow from table
$dummyRow.detach();
});
// bind an event to the sortEnd event of tablesorter
$table.bind('sortEnd',function(){
// append dummyrow before savedIndex row
if ($('tbody tr', $table).eq(savedIndex).length === 1) {
$('tbody tr', $table).eq(savedIndex).before($dummyrow);
}
else {
$('tbody', $table).append($dummyrow);
}
});