TableTools bug when .fnDestroy()'ing and re-initializing table.
TableTools bug when .fnDestroy()'ing and re-initializing table.
joeltine
Posts: 4Questions: 0Answers: 0
Im using DT 1.9 and TableTools 2.0.2.
I found a bug when trying to fnDestroy and remove a table w/ TableTools from the DOM, then re-initialize it. The Table is initialized with TableTools in both circumstances. TableTools is initialized using a button collection. I couldn't create a jsfiddle example because they don't allow flash.
The error occurs on line 133 of ZeroClipboard.js, "Unable to call appendChild on null":
this.domElement.parentNode.appendChild(this.div);
I think its because div.DTTT_collection isn't getting removed from the page when you destroy the table. So when you re-initialize it, it finds the existing .DTTT_collection buttons and tries to reuse it. I made a temporary fix by adding after my fnDestroy:
$(".DTTT_collection").remove();
right after I destroy and .remove() the table element. This seems to work.
Cheers.
P.S. If it helps here is the options I"m using for TableTools:
[code]
"sDom": 'TC<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "../js/jquery/datatables/TableTools/media/swf/copy_cvs_xls_pdf.swf",
"aButtons": [
{
"sExtends": "collection",
"aButtons": ['csv', 'pdf','xls' ]
}
]
}
[/code]
I found a bug when trying to fnDestroy and remove a table w/ TableTools from the DOM, then re-initialize it. The Table is initialized with TableTools in both circumstances. TableTools is initialized using a button collection. I couldn't create a jsfiddle example because they don't allow flash.
The error occurs on line 133 of ZeroClipboard.js, "Unable to call appendChild on null":
this.domElement.parentNode.appendChild(this.div);
I think its because div.DTTT_collection isn't getting removed from the page when you destroy the table. So when you re-initialize it, it finds the existing .DTTT_collection buttons and tries to reuse it. I made a temporary fix by adding after my fnDestroy:
$(".DTTT_collection").remove();
right after I destroy and .remove() the table element. This seems to work.
Cheers.
P.S. If it helps here is the options I"m using for TableTools:
[code]
"sDom": 'TC<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "../js/jquery/datatables/TableTools/media/swf/copy_cvs_xls_pdf.swf",
"aButtons": [
{
"sExtends": "collection",
"aButtons": ['csv', 'pdf','xls' ]
}
]
}
[/code]
This discussion has been closed.
Replies
Regards,
Allan
Allan