Stupid-Table-Plugin icon indicating copy to clipboard operation
Stupid-Table-Plugin copied to clipboard

Skip certain rows when sorting

Open pelcasandra opened this issue 11 years ago • 1 comments

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.

stupidtable

Is there any way to skip certain <tr><td>...</td</tr> from being ordered or preferently stick always under a parent sortable row?

pelcasandra avatar Jul 05 '14 02:07 pelcasandra

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);
                }
            });

cptOneEye avatar Jun 08 '20 10:06 cptOneEye