Question

I'm using jquery tablesorter in my project, and now i need some functionality i could not find in that plugin or any of it subplugins. Maybe i'm using a wrong term, but i need something like "sticky rows". Before, i had pretty standart tables, like

<table> 
<thead> 
<tr> 
<th>Head1</th> 
<th>Head2</th> 
<th>Head3</th> 
</tr> 
</thead>
<tbody> 
<tr>
<td>cell1.1</td>
<td>cell1.2</td>
<td>cell1.3</td>
</tr>
...
</tbody> 
</table>

and tablesorter worked well with it.

Now, i need something like:

<table> 
<thead> 
<tr> 
<th>Head1</th> 
<th>Head2</th> 
<th>Head3</th> 
</tr> 
</thead>
<tbody> 
<tr>
<td>cell1.1</td>
<td>cell1.2</td>
<td>cell1.3</td>
</tr>
<tr>
<td>cell1.4</td>
<td collspan="2">cell1.5</td>
</tr>
...
</tbody> 
</table>

and to keep old sorting working.

That meens, i need tablesorter to ignore row with cell1.4 and cell1.5 (and so on with the next even rows), sort the not-ignored rows in table, and than append the appropriate ignored before row to appropriate not-ignored row (so that row with cell 1.4 and 1.5 allways follow the row with cell1.1). In other worlds, i want row with cells 1.4 and 1.5 to stick to the previous row and so on. For this, i need to find the way to mark the row for the required functionality (either with tablesorter parameters or with attributes).

I didn't find appropriate functionality in tablesorter docs. How this can be achieved?

Était-ce utile?

La solution

It sounds like you're asking about child rows (demo). To make this work in tablesorter, just add the class name "tablesorter-childRow" to any row that will be attached to the row above it.

<tr>
    <td>cell1.1</td>
    <td>cell1.2</td>
    <td>cell1.3</td>
</tr>
<tr class="tablesorter-childRow">
    <td>cell1.4</td>
    <td collspan="2">cell1.5</td>
</tr>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top