Colspan and rowspan did not work in IE7

Colspan and rowspan did not work in IE7

spikerspiker Posts: 2Questions: 0Answers: 0
edited April 2009 in General
I tried complex_header example included in 1.5 beta6. It worked in Firefox, but did not work in IE7. In IE7 the browser will report error:
Line 2051
Char:6
aoColumns[...] could not be null

I tried to add aoColumns definition:
"aoColumns": [{"bSortable": true},{"bSortable": true},{"bSortable": true},{"bSortable": true},{"bSortable": true}]

The warning disappear, but the column header still not sortable.

In Firefox and Google Chrome, everything worked.

Replies

  • allanallan Posts: 54,900Questions: 1Answers: 8,605 Site admin
    Hi spiker,

    Good call - thanks for letting me know about that. Interesting one this one... For columns which don't have a colspan (or rowspan) attribute IE reports the colspan value as 1 (which actually seems reasonable), while all the other browsers report the value as 0, which is what I was switching on.

    Easy fix (fortunately!) and I'll release it in 1.5 beta 7, which I think it is about time for. It will be out shortly.

    Allan
  • spikerspiker Posts: 2Questions: 0Answers: 0
    edited April 2009
    Hi Allan,

    Good work. It worked now.

    And I found the numeric type detection function will detect date format "yyyy-MM-dd" as numeric type because it contains symbol "-", which will make the column not sortable.

    I borrowed some code from number plugin and do some quick hack to solve the problem:

    jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(x, y) {
    x = x.replace(/[^\d\-\.\/]/g, '');
    y = y.replace(/[^\d\-\.\/]/g, '');
    if (x.indexOf('/') >= 0)
    x = eval(x);
    if (y.indexOf('/') >= 0)
    y = eval(y);
    return x / 1 - y / 1;
    }
    jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(x, y) {
    x = x.replace(/[^\d\-\.\/]/g, '');
    y = y.replace(/[^\d\-\.\/]/g, '');
    if (x.indexOf('/') >= 0)
    x = eval(x);
    if (y.indexOf('/') >= 0)
    y = eval(y);
    return y / 1 - x / 1;
    }

    jQuery.fn.dataTableExt.aTypes[0] = function(sData) {
    var sValidChars = "0123456789.";
    var Char;
    var bDecimal = false;

    sData = sData.replace(/,/g, "");

    /* Check the numeric part */
    for (i = 0; i < sData.length; i++) {
    Char = sData.charAt(i);
    if (sValidChars.indexOf(Char) == -1) {
    if (Char == '-') {
    if (i == 0) {
    continue;
    } else { // Possible date
    return "natural";
    }
    continue;
    } else {
    return null;
    }
    }

    if (Char == '.') {
    if (bDecimal) {
    return null;
    }
    bDecimal = true;
    }
    }

    return "formatted-num";
    }

    Can we expect improvement on numeric detection in final release?
  • allanallan Posts: 54,900Questions: 1Answers: 8,605 Site admin
    Oo - ouch - yes. I think an improved detection algorithm for numeric sorting is certainly required given this situation. This should be trivial to do - simply look for the dash ('-') only in the first character :-) Thanks for posting the work around for the moment.

    Allan
This discussion has been closed.