'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++;
}
}
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.
Using this code fixed the problem for me, il leave the question open perhaps somone knows why it works with this change.
"aoColumns": [
{ "sType": "string", "sWidth": "auto" }, // Player name
{"sType": "numeric-minus", "sWidth": "auto" }, // Damage done
{"sType": "numeric-comma", "bVisible": false, "sWidth": "auto" }, // DPS real
{"sType": "numeric-comma", "sWidth": "auto" }, // DPS Avg
{"sType": "numeric-minus", "sWidth": "auto" }, // Damage taken
{"sType": "numeric-minus", "sWidth": "auto" }, // Healing done
{"sType": "numeric-comma", "bVisible": false, "sWidth": "auto" }, // healing done HPS
{"sType": "numeric-comma", "sWidth": "auto" }, // healing done HPS Avg
{"sType": "numeric-comma", "sWidth": "auto" }, // Overhealing
{"sType": "numeric-comma", "sWidth": "auto" }, // Healing taken
{"sType": "numeric-comma", "bVisible": false, "sWidth": "auto" }, // Mana done
{"sType": "numeric-comma", "bVisible": false, "sWidth": "auto" }, // Stamina done
{"sType": "string", "bVisible": false, "sWidth": "auto" }, // Class
{"sType": "percent", "sWidth": "auto" } // Activity
],
in my case using width="100%"
in table caused the problem, removing width solved it.
working code
<table id="dt_table">
<thead>
<tr>
<th>column1</th>
<th>column2</th>
<th>column3</th>
<th>column4</th>
<th>column5</th>
<th>column6</th>
</tr>
</thead>
</table>
精彩评论