Giter Site home page Giter Site logo

Comments (14)

mattweason avatar mattweason commented on July 18, 2024 4

What I ended up doing was just triggering a resize event after the table loaded. It's a bit hacky but it works.

from fixed-table-header.

ctqctq avatar ctqctq commented on July 18, 2024 2

I've found a better way to handle IE11

                            //checking IE11
                            var isIE = /*@cc_on!@*/false || !!document.documentMode;
                            if (isIE) {
                                clone.css({
                                    boxSizing: 'content-box'
                                });
                            }
                            clone.css({
                                width: style.width,
                                minWidth: style.width,
                                maxWidth: style.width
                            });

I was reading this earlier https://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug

from fixed-table-header.

mattweason avatar mattweason commented on July 18, 2024 1

Here's the resize event code I use:

window.dispatchEvent(new Event('resize'));

For IE you might have to use this:

var evt = document.createEvent('HTMLEvents');
evt.initEvent('resize', true, false);
window.dispatchEvent(evt);

I also put that in a setTimeout to make sure the table is fully loaded before it triggers. Like I said, it's hacky but it does the job for now.

from fixed-table-header.

ctqctq avatar ctqctq commented on July 18, 2024 1

if you have child element inside your TH, you need to set the width on the child element instead of setting the width on your TH

this is my code to fix this problem
var setWidth = function () {
marginTop(height());
//checking IE11
var isIE = /@cc_on!@/false || !!document.documentMode;
if (isIE){
clone.children().css({ width: style.width });
} else {
clone.css({ width: style.width });
}
};

from fixed-table-header.

timbrnbrr avatar timbrnbrr commented on July 18, 2024 1

Doesn't work for me.

from fixed-table-header.

ctqctq avatar ctqctq commented on July 18, 2024 1

try this too

var setWidth = function () {
marginTop(height());
//checking IE11
var isIE = /@cc_on!@/false || !!document.documentMode;
if (isIE) {
var border = parseFloat(style.borderRightWidth, 10) + parseFloat(style.borderLeftWidth, 10);
var padding = parseFloat(style.paddingRight, 10) + parseFloat(style.paddingLeft, 10);
var margin = parseFloat(style.marginLeft, 10) + parseFloat(style.marginRight, 10);
var widthToAdd = parseFloat(style.width, 10) + border + padding + margin;
console.log('width: ', widthToAdd);
clone.css({width: widthToAdd + 'px' });
} else {
clone.css({width: style.width }); //modified to set width directly instead of max and minwidth
}
};

from fixed-table-header.

apalayret avatar apalayret commented on July 18, 2024

I have the same problem, only on IE11.
And it's a little odd, because the original thead is properly line up, but not the clone.

from fixed-table-header.

timbrnbrr avatar timbrnbrr commented on July 18, 2024

Have you found a solution for this problem yet? I have experienced the same problem using Firefox and IE11.

from fixed-table-header.

timbrnbrr avatar timbrnbrr commented on July 18, 2024

What kind of resize event did you trigger?

from fixed-table-header.

praveenraji2i avatar praveenraji2i commented on July 18, 2024

Doesn't work for me also.

from fixed-table-header.

praveenraji2i avatar praveenraji2i commented on July 18, 2024

@ctqctq It's working, thank you. Please add
clone.css({
width: widthToAdd + 'px',
minWidth: widthToAdd + 'px',
maxWidth: style.width + 'px'
});

from fixed-table-header.

hgoebl avatar hgoebl commented on July 18, 2024

Thanks! You're saving my day.

My working solution looks like this (merged and corrected a bit):

          var setWidth = function () {
            marginTop(height());
            //checking IE11
            var isIE = !!document.documentMode;
            if (isIE) {
              var border = parseFloat(style.borderRightWidth) + parseFloat(style.borderLeftWidth);
              var padding = parseFloat(style.paddingRight) + parseFloat(style.paddingLeft);
              var margin = parseFloat(style.marginLeft) + parseFloat(style.marginRight);
              var widthToAdd = parseFloat(style.width) + border + padding + margin;
              console.log('width: ', widthToAdd);
              clone.css({
                width: widthToAdd + 'px',
                minWidth: widthToAdd + 'px',
                maxWidth: style.width + 'px'
              });
            } else {
              clone.css({width: style.width }); //modified to set width directly instead of max and minwidth
            }
          };

from fixed-table-header.

hgoebl avatar hgoebl commented on July 18, 2024

Thanks @ctqctq it works perfectly with IE11. Much better solution.

from fixed-table-header.

Vin-1991 avatar Vin-1991 commented on July 18, 2024

Thanks @ctqctq man you saved my life. Cheers.

from fixed-table-header.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.