customize the button print

customize the button print

jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0

when i want to print , in the preview`s print i can see my table with Title, 1 message, and the table, but i want to insert a total under the dataTable, anybody knows how can i put a message in?
Is specificly in the customize (print ).

this only works with 1 msj message: "message hello" , and appears in the head of the page

Answers

  • jfri_2007jfri_2007 Posts: 25Questions: 6Answers: 0
    edited September 2015

    with append i can put a text, buy only 1, i want 2 like this :

    TOTAL: xxxxxxxx

    SUBTOTAL : xxxxxxx

    (all this in the preview print, customize)

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Im sure this is very old, (but I cant tell, you know why @allan? theres no dates on anything! lol.... super weird). But ill answer it anyways.

    I saw the customize option and was curious what I could use it for, I found this thread in my search results, so thought id answer it..

    The DataTable.ext.buttons.print method is what handles this option, and the related code is pretty simple:

    if ( config.customize ) {
        config.customize( win );
    }
    

    For how to use it, take a look at the example, the example does exactly what you are looking to do @jfri_2007.

    buttons: [
        {
            extend: 'print',
            customize: function ( win ) {
                $(win.document.body)
                    .css( 'font-size', '10pt' )
                    .prepend(
                    '<img src="http://datatables.net/media/images/logo-fade.png" style="position:absolute; top:0; left:0;" />'
                );
    
                $(win.document.body).find( 'table' )
                    .addClass( 'compact' )
                    .css( 'font-size', 'inherit' );
            }
        }
    ]
    

    So you can append any data to the content using jQuerys $.append() or $.prepend()

  • allanallan Posts: 63,747Questions: 1Answers: 10,509 Site admin

    theres no dates on anything! lol....

    Sure there is - immediately below the forum name of the post it shows the date of when the post was created. September 15 for this thread.

    Allan

This discussion has been closed.