0

I have view in codeigniter which I am trying to enhance with datatables and the TableTools extension. I am using version 1.94 of datatables. According to R shiny dataTables with TableTools and other extensions, version 2.1.5 of table tools is needed. I have included this. I am trying to follow http://datatables.net/extensions/tabletools/ and the article above to get TableTools working, but so far there is no sign of the TableTools toolbar. What am I doing wrong?

Here's my code:

 <table id="myDataTable">
        <thead>
            <tr>
                <th>ROW</th>
                <?php foreach($keys as $key): ?>
                <th><?php echo $key; ?></th>
                <?php endforeach; ?>


            </tr>

        </thead>      
        <tbody>

           <?php $i=1; foreach($fulltable as $row): ?>
               <tr id="<?php echo $i ?>">
                <td><?php echo $i; ?></td>    

             <?php foreach($row as $cell): ?>
                <td><?php echo $cell; ?></td>
                <?php endforeach; ?>
                </tr>
                <?php $i++; endforeach;  ?>

                  </tbody>
        </table>

 <!--jQuery--> 
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>


      <!--DataTables CSS--> 
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">


 <!--DataTables--> 
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>

<!--DataTable tools--> 
<script type="text/javascript" charset="utf8" src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/TableTools.min.js'></script>
<script type="text/javascript" charset="utf8" src='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/ZeroClipboard.min.js'></script>
<link rel="stylesheet" type="text/css" href='//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/css/TableTools.min.css'>


    <script language="javascript" type="text/javascript">

            $(document).ready(function () {
                $('#myDataTable').dataTable( {
                    "dom": 'T<"clear">lfrtip',
                    "tableTools": {
                        "sSwfPath": "//cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/swf/copy_csv_xls.swf",
                    }
                });
            });

        </script>
Community
  • 1
  • 1
user1592380
  • 34,265
  • 92
  • 284
  • 515

1 Answers1

1

The TableTool plugin is a flash plugin, so the client/browser needs to have flash installed. Also, check the path you specify in "tableTools" in the initialization object. It is missing a 'http:' prefix. It should be:

"sSwfPath": "http://cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/swf/copy_csv_xls.swf"

Edit: (also see my comment below)

just to clarify better instead of:

ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js

use

cdn.datatables.net/1.10.0/js/jquery.dataTables.min.js

instead of:

cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/TableTools.min.js

use

cdn.datatables.net/tabletools/2.2.1/js/dataTables.tableTools.min.js

instead of:

cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/css/TableTools.min.css

use

cdn.datatables.net/tabletools/2.2.1/css/dataTables.tableTools.css

so the javascript section should be:

 <!--jQuery-->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>


<!--DataTables CSS-->
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">


<!--DataTables-->
<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.0/js/jquery.dataTables.min.js"></script>

<!--DataTable tools-->
<script type="text/javascript" charset="utf8" src='http://cdn.datatables.net/tabletools/2.2.1/js/dataTables.tableTools.min.js'></script>
<script type="text/javascript" charset="utf8" src='http://cdnjs.cloudflare.com/ajax/libs/datatables-tabletools/2.1.5/js/ZeroClipboard.min.js'></script>
<link rel="stylesheet" type="text/css" href='http://cdn.datatables.net/tabletools/2.2.1/css/dataTables.tableTools.css'>

You might want to check the ZeroClipboard you are linking to also. That is porbably of the wrong version also.

skarist
  • 1,030
  • 7
  • 9
  • Thanks for getting back to me. I've made the changes you suggested but still see no signs of the toolbar, flash is installed according to http://www.adobe.com/software/flash/about/ – user1592380 Jul 09 '14 at 01:40
  • ok it appears that you are connecting to the wrong versions of the javascript resources. If you replace with these: it works – skarist Jul 09 '14 at 12:41
  • Thanks again skarist, I made the changes that you recommended . The toolbar appears , but none of the buttons work except print. I see not errors in firebug – user1592380 Jul 12 '14 at 02:41
  • I'll ask this as a follow up question – user1592380 Jul 14 '14 at 21:54