print preview in a popup

print preview in a popup

shawnrummelshawnrummel Posts: 3Questions: 0Answers: 0
edited November 2012 in Plug-ins
I am a newby with JQuery and am trying to figure out how to create a print preview using the Table Tools plugins 'Print' functionality. As is the print functionality removes non-printing elements. I have a requirement to display that same representation in a pop-up. If I just use DOM manipulation I only get the first page of my dataTable. I would like the print preview in the pop-up to show all results.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Currently no - TableTools does not support this functionality. One option might be to modify TableTools to clone the table node and insert that into a new document, but its not something it does at the moment.

    Allan
  • shawnrummelshawnrummel Posts: 3Questions: 0Answers: 0
    I was able to get this most of the way completed before my requirement changed. I extended the Print click functionality and used the jqprint plugin ( which I had to modify a bit for my tastes and IE preview capability. Here is the code

    [code]
    function tablePrint(tableElement, tableId){

    var oSetDT = tableElement.s.dt;
    var oSetPrint = tableElement.s.print;

    tableElement.s.print.saveStart = oSetDT._iDisplayStart;
    tableElement.s.print.saveLength = oSetDT._iDisplayLength;

    oSetDT._iDisplayStart = 0;
    oSetDT._iDisplayLength = -1;
    oSetDT.oApi._fnCalculateEnd( oSetDT );
    oSetDT.oApi._fnDraw( oSetDT );

    var tableToPrint = $('#'+tableId);
    tableToPrint.jqprint();
    $('#printFrame').hide();

    oSetDT._iDisplayStart = oSetPrint.saveStart;
    oSetDT._iDisplayLength = oSetPrint.saveLength;
    oSetDT.oApi._fnCalculateEnd( oSetDT );
    oSetDT.oApi._fnDraw( oSetDT );

    }
    [/code]
    I am now working on getting Headers and Footers included.
This discussion has been closed.