colvis error after fnDestroy and re-init

colvis error after fnDestroy and re-init

gwsillimangwsilliman Posts: 2Questions: 0Answers: 0
edited September 2012 in General
I have an implementation of datatable that is enhancing a table supplied by ajax. This table is updated on a regular interval with additional ajax calls. The update routine calls fnDestroy, replaces the raw table, then re-initializes datatables. I am trying to add in the colvis plugin. It works fine until the table updates then I get an error in the fnSetColumnVis section of the core datatables code:

[quote]TypeError: oSettings is null
http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.js
Line 5891[/quote]

This is my code for loading the table and enhancing it.
[code]
function loadTable() {
if (myDataTable) {
myDataTable.fnDestroy;
}
$('#table').load('gettable.php?dummy=' + new Date().getTime(), function() {
myDataTable = $('#statustable').dataTable({
"bStateSave": true,
"iCookieDuration": 60*60*24,
"bFilter": false,
"bPaginate": false,
"bInfo": false,
"bJQueryUI": false,
"bSortClasses": false,
"sDom": 'C<"clear">lfrtip',
"oColVis": {
"aiExclude": [ 6 ]
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 6 ] }
],
"aoColumns": [
{ "aDataSort": [ 0 ] },
{ "aDataSort": [ 1, 0 ] },
{ "aDataSort": [ 2 ] },
{ "aDataSort": [ 3, 1, 0 ] },
{ "aDataSort": [ 4, 1, 0 ] },
{ "aDataSort": [ 5 ] },
null
]
});
$('#addbutton').click(function () {
addEntry();
});
$('.delete').click(function () {
var myurl = "delete.php?record=" + this.id;
$.ajax({
url: myurl,
cache: false
}).done(function() {
loadTable();
});
});
});
}
[/code]

Any thoughts on how to fix this?

Replies

  • gwsillimangwsilliman Posts: 2Questions: 0Answers: 0
    I think I had this in the wrong spot - moved to general. Any thoughts?
This discussion has been closed.