Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tablesorte with rowspan not work: #806

Closed
askovpen opened this issue Jan 24, 2015 · 3 comments
Closed

tablesorte with rowspan not work: #806

askovpen opened this issue Jan 24, 2015 · 3 comments

Comments

@askovpen
Copy link

tablesorte with rowspan not work:

http://jsfiddle.net/a0nghxdz/

@Mottie
Copy link
Owner

Mottie commented Jan 24, 2015

Hi @askovpen!

Tablesorter does not currently support sorting colspan or rowspan settings in the tbody; duplicate of issues #110, #485 and #746.

I do plan on adding support eventually, but it will be in the tablesorter update renamed to Abelt - it is still a work in progress.

@ioleo
Copy link

ioleo commented Feb 22, 2015

Hi @askovpen @Mottie

I've had a similar problem. I've resolved it useing event handlers:

    $('table').bind("sortEnd updateComplete",function(e, table) {
        $(table).find("[data-row]").each(function(idx, parent){
            var $parent = $(parent);
            var $rows = $(table).find('[data-parent="'+$parent.data('row')+'"]');

            // this is needed only to keep "odd"/"even" classes in sync with parent
            // uncomment only if you use zebra
            // if ($parent.hasClass('odd')) {
            //  $rows.removeClass('even').addClass('odd');
            // } else {
            //  $rows.removeClass('odd').addClass('even');
            // }

            // move rows only if needed
            if ($rows.first().prev('tr')[0] != $parent[0]) {
                $parent.after($rows);
            }

            // cancel hiding child rows
            $rows.show();
        });
    });

This requires to add data-row attribute to each "parent row" and data-parent attribute to each child row. See the fiddle below.

Note: moveing many child rows may cause performance issues. In my case, my tables were not going to contain too much rows, so I did not care.

Here is fiddle: http://jsfiddle.net/djhqmt92/

@sytolk
Copy link

sytolk commented Aug 31, 2015

Thanks @loostro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants