mkoryak/floatThead

Support hidden columns in tables that have an existing colgroup

Bibendus83 opened this issue · 4 comments

Hello!

I have a weird case where I have to hide a certain column but I need to keep it into the HTML.
Adding a display none on the colgroup caused wrong width calculations on the floating thead.

image

Here is the JSFiddle to reproduce it
https://jsfiddle.net/Bibendus/Ldmyrvb0/5/

I made a quick fix for the issue but I don't have a lot of time to review the entire code and check for possible bugs so I'm sharing my solution hoping it's of any help

in the reflow() function I added this piece of code
inside this for cycle

            for(i=0; i < numCols; i++){
              $headerCells.eq(i).width(widths[i]);
              $tableCells.eq(i).width(widths[i]);
              // MY FIX - START
              if ($tableCells.eq(i).is(':not(:visible)')) {
                $headerCells.eq(i).css('display', 'none');
              }
              // MY FIX - END
            }

This should add a display:none to the colgroup when the existing col of the original table is hidden

this is actually a bug around my poor support for <colgroup>. The workaround which may not work for you is to not use colgroup:

https://jsfiddle.net/ps9knrbj/

Do you really need it ? :)

It doesn't hurt to have the bug fixed :)

I pushed that fix to master. You should try it out and see if works any better.

Why are you using cols though?

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.