Stupid-Table-Plugin
Stupid-Table-Plugin copied to clipboard
Skip certain rows when sorting
I have a list of rows sorted by default, and they have a expand button. When clicked, it shows a few <tr><td>...</td</tr> rows hidden.
Problem is that, since rows are sorted by default, these are displayed inconsistently above the clicked row instead of below.

Is there any way to skip certain <tr><td>...</td</tr> from being ordered or preferently stick always under a parent sortable row?
Just if someone is interested. I added attributes data-id an data-parentid to the rows. After sorting i reattached the subrows to the parent rows again:
// Jquery
var table = $('.mytable').stupidtable();
table.bind('aftertablesort', function (event, data) {
var subrows = $('tr.subrow');
for (var i = 0; i < subrows.length; i++) {
var subrow = $(subrows[i]);
var parentrow = $('tr.parentrow[data-id="' + subrow.attr('data-parentid') + '"]');
subrow.insertAfter(parentrow);
}
});