TableTools using custom button.

TableTools using custom button.

rrecobarrecoba Posts: 3Questions: 0Answers: 0
edited January 2013 in TableTools
Hello,

I want to use the PDF button provided by TableTools, but i need this action to be linked to my own button, no the ones generated by TableTools. Is this possible?

I need to do this because my button for export to pdf, is in a very different place in the page (in a sidebar at the left of the screen).

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    > but i need this action to be linked to my own button, no the ones generated by TableTools. Is this possible?

    In short - no. Having said that, you can put the TableTools button anywhere you want in the DOM ( http://datatables.net/release-datatables/extras/TableTools/alt_init.html ) and style it however you need using CSS. Indeed you can even change what tags are used through the initialisation options.

    Allan
  • rrecobarrecoba Posts: 3Questions: 0Answers: 0
    Thanks Allan, i can do what i want using the example as a guide. Thanks.
    I´m having another issue right now.

    I downloaded datatables packages, and copy de the extraced directory inside the examples directory of datatables package. As a result i see a working page but the only button that woks is the print one. I tryied modifying the path to the swf without success, any idea?

    R.-
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Two options:

    1. The swf isn't being loaded
    2. The TableTools element is being initialised while hidden, and thus can't get the sizes to draw for the Flash movie. For this you need to use the API to adjust the size when it is in the DOM:

    http://datatables.net/extras/tabletools/api

    fnResizeRequired and fnResizeButtons

    Allan
  • rrecobarrecoba Posts: 3Questions: 0Answers: 0
    I cannot figure out what is wrong, i´m trying the examples that comes in tabletools package and doesn´t work. Is this a bug in the package?

    Now i´ve modified a little the code in the example: http://datatables.net/release-datatables/extras/TableTools/alt_init.html, but without succes.

    Here is my code:

    [code]

    $(document).ready( function () {
    var oTable = $('#example').dataTable();
    var oTableTools = new TableTools( oTable, {
    "sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
    "buttons": [
    "copy",
    "csv",
    "xls",
    "pdf",
    { "type": "print", "buttonText": "Print me!" }
    ]
    } );

    $('#demo').before( oTableTools.dom.container );
    oTableTools.fnResizeRequired(true);
    oTableTools.fnResizeButtons();

    } );
    [/code]

    Regards,
This discussion has been closed.