Browser Compatibility problem
Browser Compatibility problem
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 ?
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 ?
This discussion has been closed.
Replies
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.
[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
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
[code]
, "bSortable": false
[/code]
and it work correctly, even with IE7.
Have a great working day, everyone
Allan