Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'style' is null or not an object

Im having some issues with datatables.net and internet explorer 8 ( Could also be other browsers, but works in IE9). I have spent some time trying to find out what the issue is and i have been unable, but i have figured out what javascript that seems to trigger it:

If i remove this code then it works in IE 8, can someone point out the error in my ways ?

"aoColumns": [
    { "sType": "string" },                       // Player name
    { "sType": "numeric-minus" },                       // Damage done
    { "sType": "numeric-comma", "bVisible": false },    // DPS real
    { "sType": "numeric-comma" },                       // DPS Avg
    {"sType": "numeric-minus" },                        // Damage taken
    {"sType": "numeric-minus" },                        // Healing done
    {"sType": "numeric-comma", "bVisible": false },    // healing done HPS
    {"sType": "numeric-comma" },    // healing done HPS Avg
    { "sType": "numeric-comma" },                       // Overhealing
    { "sType": "numeric-comma" },                       // Healing taken
    { "sType": "numeric-comma", "bVisible": false },    // Mana done
    { "sType": "numeric-comma", "bVisible": false },    // Stamina done
    {"sType": "string", "bVisible": false },            // Class
    {"sType": "percent" },                              // Activity
],

Error details from IE 8
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Thu, 28 Jul 2011 09:59:45 UTC    

Message: 'style' is null or not an object
Line: 5585
Char: 7
Code: 0
media/js/jquery.dataTables.js

Lines from datatable around error ( Error line has comment behind it ).

Function: _fnGetUniqueThs Purpose: Get an array of unique th elements, one for each column
Returns: array node:aReturn - list of unique ths
Inputs: object:oSettings - dataTables settings object
node:nHeader - automatically detect the layout from this node - optional
array object:aLayout - thead/tfoot layout from _fnDetectHeader - optional

var nThs = _fnGetUniqueThs( oSettings, nTheadClone );
iCorrector = 0;
for ( i=0 ; i<iColums ; i++ )
{
    var oColumn = oSettings.aoColumns[i];
    if ( oColumn.bVisible && oColumn.sWidthOrig !== null && oColumn.sWidthOrig !== "" )
    {
        nThs[i-iCorrector].style.width = _fnStringToCss( oColumn.sWidthOrig );
    }
    else if ( oColumn.bVisible )
    {
        nThs[i-iCorrector].style.width = ""; // This is the error line
    }
    else
    {
        iCorrector++;
    }
}
like image 774
EKS Avatar asked Dec 21 '22 10:12

EKS


1 Answers

The problem is most likely your last object in the aoColumns array:

    {"sType": "percent" },   
],

You've left the comma on the last entry. I made the same error and it worked happily with Firefox at least, but not IE 8.

like image 136
Adam Field Avatar answered Dec 24 '22 01:12

Adam Field