0

I have added this JavaScript if statement to my MVC 5 project however this does not add the table tools to the page, also I have no console errors.

if ($(".table").hasClass("ExportDataTable")) {
    $('.table').dataTable({
        "columnDefs": [
          { "type": "date", "targets": 0 }
        ],
        "order": [[0, "desc"]],
        responsive: true,
        "dom": 'T<"clear">lfrtip',
        "oTableTools": {
            "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls.swf",

        }
    });
}
else {
    $('.table').dataTable({
        "columnDefs": [
          { "type": "date", "targets": 0 }
        ],
        "order": [[0, "desc"]],
        responsive: true
    });
}
  • Might seem like an obvious question, but have you included the [tabletools code?](https://datatables.net/release-datatables/extensions/TableTools/js/dataTables.tableTools.js) – markpsmith Nov 24 '14 at 13:13
  • You are right however MVC bundles didn't want to work so I have now hard coded the script tag to the view, Thanks – Jake Lambourn Nov 24 '14 at 14:19

0 Answers0