IE7 header colspan bug

IE7 header colspan bug

jerrosenbergjerrosenberg Posts: 7Questions: 0Answers: 0
edited August 2011 in Bug reports
Using DataTables 1.8.0. Run this in IE7: http://jsfiddle.net/SUA56/

You can see that the columns are misaligned and confused. It works fine in IE8, 9, and Chrome.

The situation only occurs when you have multiple header rows in the thead with a th in the top row that colspans the bottom row, and there are columns in the colspanned section which are marked invisible in aoColumns, so the colspan of the topmost th should be reduced to only span the visible columns.

I can see that you are calculating and setting the colspan correctly on the th (last line of _fnDrawHead), but unfortunately, IE7 doesn't pick it up when you set it via setAttribute.

If you set the colSpan property directly on the element, it works fine.

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited August 2011
    These problems are usually fixed by using a <!doctype> that forces IE to act more strict and compliant:
    [code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    [/code]

    I don't imagine you'll be able to change that on jsfiddle, but for your production version you can.


    http://en.wikipedia.org/wiki/Quirks_mode
    http://www.quirksmode.org/css/quirksmode.html
    http://www.cs.tut.fi/~jkorpela/quirks-mode.html
    http://www.htmlhelp.com/tools/validator/doctype.html
  • jerrosenbergjerrosenberg Posts: 7Questions: 0Answers: 0
    We are using XHTML 1.0 Strict. But FYI, this is a known issue in IE7. It turns out if you change the setAttribute line in _fnDrawHead to say colSpan (capital S) instead of colspan, it works fine in IE7.

    See http://stackoverflow.com/questions/398734/colspan-all-columns/974215#974215
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    maybe it's the opposite. sometimes you switch OUT of strict mode into a quirks mode to fix IE stuff. it gives me a headache thinking about.
  • jerrosenbergjerrosenberg Posts: 7Questions: 0Answers: 0
    :) Thanks, but that is not an option.

    This is caused by a bug in IE7, but there is indeed a bug in datatables by not accounting for it with a known workaround. It is something that could easily be corrected in a future release so I don't have to hack the source to do it myself.
  • jerrosenbergjerrosenberg Posts: 7Questions: 0Answers: 0
    But for the record, I tried it, and changing or removing the doc mode does not resolve the issue. It needs to be fixed in the source.
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    [quote]jerrosenberg said: there is indeed a bug in datatables by not accounting for it with a known workaround[/quote]

    lol - a bug for not working with a bug in a different product! It is most frustrating that bug then. Interestingly fnOpen does work in IE7 ( http://datatables.net/release-datatables/examples/api/row_details.html ) which also uses .rowspan, so I think there is need of a bit more investigation here. I'll look into it a bit.

    Allan
  • jerrosenbergjerrosenberg Posts: 7Questions: 0Answers: 0
    [quote]lol - a bug for not working with a bug in a different product![/quote]

    that's the web we live in, right? :) I don't mean any offense, just letting you know about a problem..

    fnOpen works because you are already doing there what I suggested, setting .colSpan directly on the element. The reason _fnDrawHead does not work is because you are using setAttribute to do it, and IE7 requires you to camel case 'colSpan' when setting it that way.
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Heh - yup that's the way it goes! I've just updated the header drawing function to use the old DOM0 properties rather than setAttribute, and that's available from the downloads page as the nightly now: http://datatables.net/download .

    Thanks for flagging this up and proposing the fix!

    Regards,
    Allan
This discussion has been closed.