How to call event handler for PRINT button

How to call event handler for PRINT button

DenonthDenonth Posts: 76Questions: 0Answers: 0
edited October 2012 in General
How can I call event handler when I click print button on the table tools? I need to hide one div when I press print button and before it goes in the print mode?

Replies

  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    anyone?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Just like you would with any other jQuery click event handler no?

    [code]
    $('a.DTTT_button_print').click( ... );
    [/code]
  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    Allan thank you for that info. Is it possible to change print layout? For example to add some elements that will be inside the print area together with the datatable?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    You can use http://datatables.net/extras/tabletools/button_options#sMessage or the fact that the class 'DTTT_Print' is added to the body when in print view.

    Allan
  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    Well I found that your function is removing all the tags from bellow or above the table? I need to be able to choose that for example the bellow the table needs to be show?? Do you understand what I need?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Yes, and currently it isn't directly possible in TableTools. If you fork and add the feature (perhaps fire an event) if you could give me a pull request that would be great, as a 'printView' event sounds like it would be very useful.

    Allan
  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    Allan is it possible to have a PRINT button as a collection of Table Tools buttons that won't open your print mode? I am using your handler to start certain code when you click the button but I need to disable this possibility?

    I will post the code later when I succeed to make a customized layout.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Sure - just use a plain old button and assign an fnClick action to it. Then you can do whatever you want with the document :-)

    Allan
  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    Can you give me some example? I didn't understand you...so you are saying that I can use your print button with that fnClick?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    No, I'm saying use a 'text' button ( http://datatables.net/extras/tabletools/buttons#text ) and assign an fnClick function to it. That function can then do whatever you want.

    Allan
  • DenonthDenonth Posts: 76Questions: 0Answers: 0
    Thank you
This discussion has been closed.