DataTools buttons show but don't work when there are two tables on the page

DataTools buttons show but don't work when there are two tables on the page

RdeBoerRdeBoer Posts: 10Questions: 0Answers: 0
edited November 2013 in Bug reports
Hi,
I'm finding that when using DataTools to display the "Copy, CSV, Excel, PDF, Print" buttons, the buttons don't work when there are two sets of them, one for each of the two tables on the page.

The browser console shows errors like this one (one for each button, except Print):

.../media/swf/copy_csv_xls_pdf.sw
Failed to load resource: the server responded with a status of 404 (Not Found)

Indeed the link should be ".../extras/TableTools/media/swf/copy_csv_xls_pdf.swf", which is what DataTables does generate correctly when there's only one table with export buttons.

Any ideas?

Thanks in advance.

RdeBoer

Replies

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    Sounds like you need to use sSwfPath to set the location of the file: http://datatables.net/release-datatables/extras/TableTools/swf_path.html

    Allan
  • RdeBoerRdeBoer Posts: 10Questions: 0Answers: 0
    Hi Allan,
    Thanks so much for your prompt reply! You give great support.

    My code does use sSwfPath to set the path through the dataTable and it works great when the 'table' selector returns only one table, but not so great when I change to selector to return both tables on the page.
    So this works perfectly:
    [code]
    $(".view-display-id-block_1 table").dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sSwfPath": "sites/all/libraries/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
    }
    });
    [/code]
    ....whereas this does not:
    [code]
    $("table").dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sSwfPath": "sites/all/libraries/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
    }
    });
    [/code]
    The buttons appear correctly, but when clicked nothing happens as the underlying URL points to "/media/swf/copy_csv_xls_pdf.swf " as opposed to "sites/all/libraries/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"

    Thanks for your help!
    Rik
  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    That's odd! Can you link to your page so I can take a look and see what is going wrong please? What version of DataTables are you using?

    Allan
This discussion has been closed.