TypeError: Result of expression 'sData' [null] is not an object.

TypeError: Result of expression 'sData' [null] is not an object.

atcatc Posts: 14Questions: 0Answers: 0
edited February 2010 in Bug reports
Hi Allan,

for some reason, after upgrading to version 1.6 (and subsequently to 1.6.1), I started getting this error with some, but not all, of my datatables:

TypeError: Result of expression 'sData' [null] is not an object.

I made a small modification to the datatables code to work around this issue, but I thought you might like to be aware of it, and/or have an actual explanation for the problem rather than just a workaround. I don't *think* it's a problem with my code or my data since it's working with some tables, and with all tables in 1.5.4, but I won't be shocked if I'm mistaken : )

Here are the lines I changed (starting at 3207):
from this:
[code]
function _fnDataToSearch ( sData, sType )
{
if ( typeof _oExt.ofnSearch[sType] == "function" )
{
return _oExt.ofnSearch[sType]( sData );
}
else if ( sType == "html" )
{
return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
}
else if ( typeof sData == "string" )
{
return sData.replace(/\n/g," ");
}
return sData;
}
[/code]
to this:
[code]
function _fnDataToSearch ( sData, sType )
{
if (sData !== null) { //*atc*//
if ( typeof _oExt.ofnSearch[sType] == "function" )
{
return _oExt.ofnSearch[sType]( sData );
}
else if ( sType == "html" )
{
return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
}
else if ( typeof sData == "string" )
{
return sData.replace(/\n/g," ");
}
} //*atc*//
return sData;
}
[/code]

Thanks, as always, for the terrific tool.

Best regards,
Alison

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Hi Alison,

    It looks like you've added (to some degree) support for 'null' in DataTables. Given that null is the absence of data, I'm not entirely sure how it should be treated by DataTables - which of course is a data display component. There is a discussion about that here: http://datatables.net/forums/comments.php?DiscussionID=1178 . All input is welcome. I'm just wondering if there might be other issues with null in DataTables other than the one your fixed above - I suspect there will be. My current preferences it to replace null with an empty string on adding the data to the table.

    Regards,
    Allan
This discussion has been closed.