Null errors on Simple Implementation
Null errors on Simple Implementation
pbrstreetgang
Posts: 6Questions: 0Answers: 0
I have what I believe to be a very simple implementation of DataTables 1.7.2. I am running my own AJAX script that goes out and retrieves data based on a user's actions. The returned data set is put into an array of JavaScript objects and these are subsequently passed to a function where each object is displayed as a row using DataTables. And this all works fine.
However when a user reruns the AJAX call, i want to reset the table using oTable.fnDestroy() and then repopulate it with the data returned from the AJAX call. However, when I try this using jquery.dataTables.min.js I get a 'a is null' error:
Line 45:
[code]
a.oClasses.sSortableNone;b.sSortingClassJUI=""}else if(j.inArray("asc",b.asSorting)!=-1&&j.inArray("desc",b.asSorting)==-1){b.sSortingClass=a.oClasses.sSortableAsc;b.sSortingClassJUI=a.oClasses.sSortJUIAscAllowed}else if(j.inArray("asc",b.asSorting)==-1&&j.inArray("desc",b.asSorting)!=-1){b.sSortingClass=a.oClasses.sSortableDesc;b.sSortingClassJUI=a.oClasses.sSortJUIDescAllowed}}function w(a,b){if(b.length!=a.aoColumns.length&&a.iDrawError!=a.iDraw){J(a,0,"Added data (size "+b.length+") does not match known number of columns ("+
[/code]
When i try just using jquery.dataTables.min.js, i get the error 'oSettings is null'
Line 2477:
[code]
if ( aDataSupplied.length != oSettings.aoColumns.length &&
[/code]
I tried declaring oSettings in my implementation, but this has done nothing to resolve the issue.
Any help anyone can provide is appreciated.
Thanks,
pbr
However when a user reruns the AJAX call, i want to reset the table using oTable.fnDestroy() and then repopulate it with the data returned from the AJAX call. However, when I try this using jquery.dataTables.min.js I get a 'a is null' error:
Line 45:
[code]
a.oClasses.sSortableNone;b.sSortingClassJUI=""}else if(j.inArray("asc",b.asSorting)!=-1&&j.inArray("desc",b.asSorting)==-1){b.sSortingClass=a.oClasses.sSortableAsc;b.sSortingClassJUI=a.oClasses.sSortJUIAscAllowed}else if(j.inArray("asc",b.asSorting)==-1&&j.inArray("desc",b.asSorting)!=-1){b.sSortingClass=a.oClasses.sSortableDesc;b.sSortingClassJUI=a.oClasses.sSortJUIDescAllowed}}function w(a,b){if(b.length!=a.aoColumns.length&&a.iDrawError!=a.iDraw){J(a,0,"Added data (size "+b.length+") does not match known number of columns ("+
[/code]
When i try just using jquery.dataTables.min.js, i get the error 'oSettings is null'
Line 2477:
[code]
if ( aDataSupplied.length != oSettings.aoColumns.length &&
[/code]
I tried declaring oSettings in my implementation, but this has done nothing to resolve the issue.
Any help anyone can provide is appreciated.
Thanks,
pbr
This discussion has been closed.
Replies
Thanks,
Allan
oSettings is null
In a tag in the head, I initialize the table with:
[code]
var oTable;
$(document).ready(function()
{
oTable = $('#resultSet').dataTable();
});
[/code]
the table is defined in the body as:
[code]
Col 1
Col 2
Col 3
Col 4
Col 5
[/code]
i use a for loop in the following function to populate the table once the AJAX call returns:
[code]
function PopulateResultSet(resultSet)
{
for(i = 0; i < resultSet.length; i++)
{
oTable.fnAddData([
resultSet[i].val1,
resultSet[i].val2,
resultSet[i].val3,
resultSet[i].val4,
resultSet[i].val5
]);
}
}
[/code]
when the AJAX call is rerun, I run the following command, which appears to be triggering the JS error:
[code]
oTable.fnDestroy();
[/code]
This page is still in development and therefore is entirely local, so I cannot point you to an example online.
Thanks for any debugging help you can provide.
pbr
Mozilla identifies the JS error in the jquery.DataTables.js file in the function at line 2477:
[code]
function _fnAddData ( oSettings, aDataSupplied )
{
/* Sanity check the length of the new array */
if ( aDataSupplied.length != oSettings.aoColumns.length &&
oSettings.iDrawError != oSettings.iDraw )
{
_fnLog( oSettings, 0, "Added data (size "+aDataSupplied.length+") does not match known "+
"number of columns ("+oSettings.aoColumns.length+")" );
oSettings.iDrawError = oSettings.iDraw;
return -1;
}
[/code]
Again, thanks for any help you can provide.
pbr
Allan
I switched the fnDestroy() to fnClearTable() and everything worked great. I guess I was not reinitializing the table after destruction it.
Thanks for your help, and great work on this plug-in.
pbr