TableTools not loading into DataTables

The live data works great, but I'm trying to add TableTools and I'm having problems. Thanks to what I am using in the datasheets, everything works fine as intended without any problem, however trying to add the tableted tools to it was not successful. The console errors are not reported with what I am doing until nothing is displayed. This makes me think that I am doing something wrong in the code. I have put the code below.

The script includes:

        <script src="//cdn.datatables.net/1.9.4/js/jquery.dataTables.js"></script>
        <script src="//cdn.datatables.net/tabletools/2.2.0/js/dataTables.tableTools.js"></script>
        <script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
        <link rel="stylesheet" href="//cdn.datatables.net/tabletools/2.2.0/css/dataTables.tableTools.css" type="text/css" media="all" />

      

I am using the following code:

        var foreTable = $(".cscf-fore-table").dataTable({dom: \'T<"clear">lfrtip\',
            tableTools: {
                "sSwfPath": "//cdn.datatables.net/tabletools/2.2.0/swf/copy_csv_xls.swf",
                "aButtons": [
                "copy",
                "csv",
                "xls",
                "print"
                ]
            },
                "bSort": false,"aLengthMenu": [
                [25, 50, 100, 200, -1],
                [25, 50, 100, 200, "All"]
                ],
            "iDisplayLength":-1, "bJQueryUI":true, "sPaginationType":"full_numbers"});  

      

+3


source to share


1 answer


First, the fiddle you forked doesn't work because you are importing tabletools.js

/ .css

before dataTables.js

and .css

.

The main reason TableTools doesn't work for you is the combination between 1.10.x naming convention for camel and Hungarian 1.9.x notation. Have you probably done any updates / copypaste from the examples? You have:

dataTable({
   dom: 'T<"clear">lfrtip',

      

But it dom

was named sDom

before 1.10.x. In 1.10.x, you can use either dom

or sDom

, but only knows dataTables 1.9.4 sDom

. Just change to



dataTable({
   sDom: 'T<"clear">lfrtip',

      

This is why there were no errors in the console. The TableTools was never initialized, your whole dom

-declaration was ignored.

Look at the fiddle again, now working - dataTables 1.9.4 and tableTools 2.2.2 -> http://jsfiddle.net/7ng9wfak/

+1


source







All Articles