Browser Compatibility problem

Browser Compatibility problem

bubuzzzbubuzzz Posts: 26Questions: 0Answers: 0
edited August 2011 in General
Dear all,

I use the following code to render datatable in my current project

[code]
oTable = $jq16('#example').dataTable({
"bJQueryUI" : true,
"sPaginationType": "full_numbers",
"bServerSide":true,
"bProcessing": true,
"bFilter": false,
"iSortingCols": 3,
"sAjaxSource": "<%=request.getContextPath()%>/jsp/struts/directory/sfeDirData.do?method=processing",
"aoColumns": [
{ "mDataProp": "directoryName"},
{ "mDataProp": "path"},
{ "mDataProp": "temp"},
{ "mDataProp": null, "bSortable": false},
{ "mDataProp": null, "bSortable": false},
],

"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
if ( oObj.aData["directoryName"] == "dede") {
return "Delete";
}
else {
return "N/A";
}

},
"aTargets": [3]
},

{
"fnRender": function ( oObj ) {
if ( oObj.aData["directoryName"] == "dede") {
return "Edit";
}
else {
return "N/A";
}

},
"aTargets": [4]
},
],
});

[/code]

it runs smoothly with IE 9, FF and Chrome. However,datatable cannot be rendered correctly when i switch the browser mode of IE into IE 8. In the console debugging, i got the error message:
[code]
SCRIPT5007: Unable to get value of the property 'aTargets': object is null or undefined
jquery.dataTables.js, line 7200 character 6
[/code]

Do you have any suggestion about how to fix it ?

Replies

  • StephanStephan Posts: 20Questions: 0Answers: 0
    IE8 seems to have a problem with your "mDataProp": null

    You could generate the href or "N/A" String server_side, but i guess you have your reasons doing this client_side.
    Why not filling it with "N/A" initially and only replacing it if (oObj.aData["directoryName"] == "dede"), this way there would not be any null reference in the object.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You have trailing commas in your code:

    [code]
    },
    ],
    });
    [/code]

    for example. IE will throw and error at this, while Firefox and others will allow it (presumably it is in the ECMAScript specification, although personally I'd say that IE8 was correct - the syntax is invalid). Just remove the trailing commas and it should work okay :-)

    Allan
  • bubuzzzbubuzzz Posts: 26Questions: 0Answers: 0
    Hi allan,

    That is what i thought after the previous post. Sadly, after removing all the trailing commas, datatable still cannot be rendered correctly (no data in the table when in the IE8 mode). The debug message is [code]
    SCRIPT5007: Unable to get value of the property 'style': object is null or undefined
    jquery.dataTables.js, line 5585 character 7
    [/code]

    Thank Stephan, i will be trying to find the way around
  • bubuzzzbubuzzz Posts: 26Questions: 0Answers: 0
    Horray, it is fixed. I just remove all the trailling commas and also remove attribute
    [code]
    , "bSortable": false
    [/code]

    and it work correctly, even with IE7.

    Have a great working day, everyone
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    That should work - I'll look into that - thanks for the heads up.

    Allan
This discussion has been closed.