Search code examples
jquerytwitter-bootstrapdatatablestabletools

Setting swf path when using bootstrap styling in datatables


I am using the bootstrap styling option in datatables. Now I am getting the layout which I want but the export buttons are not working. Initially it was working fine, but when I am using it with bootstrap it doesn't. Path is right. Also is this how you do it? Most probably i am wrong. I am following this example. http://www.datatables.net/release-datatables/extensions/TableTools/examples/bootstrap.html

$(document).ready(function() {
var table = $('#example').DataTable();
var tt = new $.fn.dataTable.TableTools( table );
//tt.sSwfPath = "extensions/TableTools/swf/copy_csv_xls_pdf.swf";
 $( tt.fnContainer() ).insertBefore('div.dataTables_wrapper');
 tt:{
 sSwfPath : "extensions/TableTools/swf/copy_csv_xls_pdf.swf";
 };

} );

Solution

  • You are not sending the TableTools option correctly. See second parameter in the example: http://www.datatables.net/release-datatables/extensions/TableTools/examples/new_init.html

    Here is how I initialize TableTools :

    var dtTableToolsOptions= {
            aButtons:     [ 'select_all', 'select_none' , 'copy', 'csv', 'xls', 'pdf', 'print'],
            sSwfPath: "http://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf"
    }
    var tt = new $.fn.dataTable.TableTools(table, dtTableToolsOptions);
    
    
    $(tt.fnContainer()).insertBefore('div.dataTables_wrapper');