Automatically added colgroup is broken if first row has internal tables
pekkaklarck opened this issue · 3 comments
First of all, it seems that tablesorter functionality has changed and it nowadays always adds colgroups to tables. With earlier versions that apparently was done only when widthFixed was set. I'm not sure was this such a good change because tablesorter overwrites possibly original colgroup and I would assume that's not always a good idea.
The actual problem I found with my tables was that if there is an internal table, tablesorter adds too many col elements to the colgroup it creates. This breaks the table layout pretty badly.
If I understood the code correctly, the bug occurs because "tr:first td" selector used in fixColumnWidth function matches also cells in the internal table.
I ended up fixing this problem with the following workaround:
var config = {...};
var table = $('#...');
table.tablesorter(config);
// remove possibly invalid colgroup added by tablesorter
// https://github.com/Mottie/tablesorter/issues/238
table.find('colgroup').remove();
I would prefer tablesorter not adding the colgroup for me in the first place.
Hi Pekkaklarck!
You're right, I'll revert the code to the way it was originally. I actually changed it because I was going to make the resize widget adjust the <col>
size instead of the header cells, but that didn't work out as planned.
Thanks for reporting this issue! Look for the change in the next update.
Great that no unnecessary, and possible broken, colgroups are added anymore. I'll update to the latest version immediately.
One a quick look at revision f6185db, it seems that if colgroup is added, it still gets too many cols if the first line has an internal table. That isn't a problem for me, though, since I don't use widthFixed.