data table print

data table print

krishnasinghkrishnasingh Posts: 6Questions: 2Answers: 0
edited September 2014 in Free community support

hi, am using datatable.js to draw a table for report. below is the code..
report runs fine but when in click print then in print preview it shows only 20,30 rows with scrollbar.. how can i make it printer friendly.

http://live.datatables.net/sumegobo/3/edit

jqv111('#report-results').dataTable({
"scrollY": Math.round($(window).height() * 0.90),
"scrollX": Math.round($(window).width() * 0.895),
"ordering": false,
"searching": false,
"paging": false,
//"autoWidth": true,
"info": false
});

    jqv111('html, body').animate({
        scrollTop: $("#content_primary").offset().top
    }, 1000);

    var tableH = jqv111('#report-results').height() + 25;
    var windowH = $(window).height() - $('div.reports-section').offset().top - 25;
    var reportH = 0;
    if (tableH > windowH) {
        reportH = windowH;
    }
    else {
        reportH = tableH;
    }

    jqv111('div.dataTables_scrollBody').css('height', reportH);

Answers

  • krishnasinghkrishnasingh Posts: 6Questions: 2Answers: 0

    well tried below approach.
    1. on print click create a new in memory table and fill it with cloned cells from orignal rendered table

    1. append this table to dom, hide original table
    2. use settimout to reset ie to remove the temp table and show the original table
    3. call browser print() method
    4. print dialog will come up and will show table without scroll and is printer friendly.
    5. on close of print dialog code in settimeout will fire up and reset the table back to orginal..
  • allanallan Posts: 61,759Questions: 1Answers: 10,111 Site admin

    For a print view you could try using TableTools: http://live.datatables.net/voxuwedi/1/edit .

    Allan

This discussion has been closed.