Click here to Skip to main content
15,883,798 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
suppose, i have a table that contains many rows. i want to print the table using jQuery datatable and how to export pdf from datatable.

What I have tried:

JavaScript
$(document).ready(function () {
        //Jquery Data Table
        $('#table-id').dataTable({
            "pagingType": "full_numbers",
            "lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
            "scrollY": "400px"
        });
    });
Posted
Updated 5-Dec-16 5:59am
v3

1 solution

There is exports feature available in jquery datatables, you just need to specify that what kind of exports do you want to support like:

JavaScript
$(document).ready(function () {
  //Jquery Data Table
  $('#table-id').dataTable({
    "pagingType": "full_numbers",
    "lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
    "scrollY": "400px",
    "buttons": ['pdf']
  });
});



You can also see working example with source code here
 
Share this answer
 
v3
Comments
Afzaal Ahmad Zeeshan 5-Dec-16 15:04pm    
5ed.
Ehsan Sajjad 5-Dec-16 15:07pm    
thanks. (y)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900