Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~
https://mottie.github.io/tablesorter/docs/
2.61k stars 754 forks source link

Keep groups collapsed when editing (feature request) #514

Closed terwarf closed 10 years ago

terwarf commented 10 years ago

Hi Mottie,

thanks a lot for fixing #487, works like a charm for me. There's one additional wish from me: When you have some groups collapsed and edit a row in another group, all groups extend again - on long lists this mean you'll lose focus on the row. Would be very nice to keep collapsed groups collapsed.

On fiddeling around I also noticed that setting group_collapsed leads to an empty table.

To try out:

Mottie commented 10 years ago

Hi @terwarf!

Thanks for reporting the issue with the group_collapsed option, I'll have that fixed up in the next update.

It'll take a bit more work, but I'll try to include a save option as well.

terwarf commented 10 years ago

Hi Mottie,

sadly i have to report that this still not works properly for me - maybe because I use more widgets? I've updated the fiddle to reflect more of what I'm doing with tablesorter:

http://jsfiddle.net/NtgFr/9/

To test:

  1. Expand Group "10 - SOMEVALUE"
  2. Edit a value in column 0
  3. press enter...

Am I missing something?

Thank you again for this great plugin.

Mottie commented 10 years ago

The problem is that the group_saveGroups option uses the text from the .group-name element to save the collapsed groups. And the callback is changing it immediately after.

So, in this demo I added a span after the "group-name" element and everything works great.

group_callback : function(cell, rows, column, table) {
    if( cell.find(".group-name").text() !== '' ) {
        cell.find(".group-name").after( '<span class="group-name2"> - somevalue</span>' );
    }
}

Please leave this issue open, so it will remind me to do the saving of group names after the callback. :P

terwarf commented 10 years ago

Thanks a lot, working perfectly for me now. Thumbs up.