TypeError: TableTools is not a constructor

TypeError: TableTools is not a constructor

mdalvimdalvi Posts: 2Questions: 0Answers: 0
edited March 2014 in TableTools
I am working with TableTools 2.2.0 and I am trying to initialise TableTools using "new" keyword as explained in http://datatables.net/extras/tabletools/initialisation

My code is as follows:

[code]




[/code]

Javascript:
[code]
var tblmain = $("#tblmain").dataTable({
"sDom": 'T<"clear">lfrtip',
"sScrollY": 600,
"bPaginate": true,
"bScrollCollapse": true
});
var oTableTools= new TableTools( tblmain, {
"sSwfPath": "assets/plugins/DataTables-1.9.4/TableTools-2.2.0/swf/copy_csv_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
{
"sExtends": "copy",
"bSelectedOnly": true
},
{
"sExtends": "print",
"bSelectedOnly": true
},
{
"sExtends": "csv",
"bSelectedOnly": true
},
{
"sExtends": "xls",
"bSelectedOnly": true
},
{
"sExtends": "pdf",
"bSelectedOnly": true
}]
});
$('#div_sheet').before( oTableTools.dom.container );
[/code]

This causes my firebug console saying:
-----------------------------------------
TypeError: TableTools is not a constructor
"bSelectedOnly": true
-----------------------------------------
However, if I write all TableTools options using oTableTools property along with datatable options everything works fine, so why such error when initialising using "new" keyword?

Apologize but I tried to post the test case using http://live.datatables.net but I could not replicate the situation.

Thanks..

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Try the 2.2.1-dev version: http://datatables.net/download/build/dataTables.tableTools.nightly.js?_=60133663e907c73303e914416ea258d8

    I think it should be resolve there.

    I would also point out that `new $.fn.dataTable.TableTools(...)` is now the preferred form. The `TableTools` global is still in 2.2.x, but will be removed in 2.3+.

    Allan
  • mdalvimdalvi Posts: 2Questions: 0Answers: 0
    edited March 2014
    That worked :) Thanks allan. Cheers............

    Ooh and thanks for the additional info
This discussion has been closed.