tablesort icon indicating copy to clipboard operation
tablesort copied to clipboard

Group with previous row?

Open frumbert opened this issue 6 years ago • 0 comments

Is there a way to create rows in the table that are grouped with the previous row as far as sorting is concerned?

Say I had this ridiculous example:

<table><thead><tr><th>Id</th><th>name</th></tr></thead>
<tbody>
<tr><td>4</td><td>David</td></tr>
<tr class="group-with-previous"><td colspan="2"><td>Hates to be called Dave</td></tr>
<tr><td>1</td><td>Alice</td></tr>
<tr><td>5</td><td>Edward</td></tr>
<tr><td>3</td><td>Charles</td></tr>
<tr><td>2</td><td>Bob</td></tr>
</tbody></table>

after sorting on column 1 (id) it would then look like:

<table><thead><tr><th>Id</th><th>name</th></tr></thead>
<tbody>
<tr><td>1</td><td>Alice</td></tr>
<tr><td>2</td><td>Bob</td></tr>
<tr><td>3</td><td>Charles</td></tr>
<tr><td>4</td><td>David</td></tr>
<tr class="group-with-previous"><td colspan="2"><td>Hates to be called Dave</td></tr>
<tr><td>5</td><td>Edward</td></tr>
</tbody></table>

In this case, the <tr> that has the classname group-with-previous is ignored when sorting, but when its previous row is moved in the dom it also is moved adjacent to it.

frumbert avatar Apr 09 '18 06:04 frumbert