Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datatables, TableTools Plugin Buttons are not visible

I have downloaded Jquery's dataTables.tableTools.js and dataTables.buttons.js along with the matching styles. I have confirmed that links are correct.

The issue is that my datatable works just fine, but when I add a button for exporting to csv it does not show up. The rest of the table is perfect, there are no errors according to firebug. It just will not display the button. I am using Jquery's guide to tableTool buttons to do my script. Here is mine:

$("#table").DataTable({
  buttons: [ 
    'csv'
  ]
 });

Can any one help me? I see a ton of similar questions but they all are using flash. This should just use HTML5. Am I missing something this is my first time using tableTools.

like image 319
Chris Avatar asked Feb 26 '26 02:02

Chris


1 Answers

This is how i usually generate my datatables, maybe it helps.

$('#myTable').DataTable({
            "bAutoWidth": false,
            "dom": 'lf T<"clear"> rtip',
            "tableTools": {
                "sSwfPath": "/swf/copy_csv_xls_pdf.swf",
                "aButtons": ["print"]
            },...

This should automatically take the tools when you have the bundle imported.

bundles.Add(new StyleBundle("~/Content/datatables").Include(
                    "~/Content/DataTables-x.xx.x/css/jquery.dataTables.min.css",
                    "~/Content/DataTables-x.xx.x/css/dataTables.tableTools.min.css"));

bundles.Add(new ScriptBundle("~/bundles/datatables").Include(
                    "~/Scripts/DataTables-x.xx.x/jquery.dataTables.min.js",
                    "~/Scripts/DataTables-x.xx.x/dataTables.tableTools.js"));

@Scripts.Render("~/bundles/datatables")
@Styles.Render("~/Content/datatables")

Make sure you have the correct swf in your Content/Datatables/swf folder.

like image 176
Yaw Avatar answered Feb 28 '26 16:02

Yaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!